我試圖簡單地啓動第三方應用程序時,當確定按鈕被選中。我有下面的代碼,但它不會在一起。我是一個新手,不能完全弄明白。啓動第三方應用程序
public class Abc extends Activity {
static final String MARKET_SEARCH_Q_PNAME_ANDRIOS = "market://search?q=pname:com.3rdparty.app";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.getpft);
setTitle("Install 3rd party app?");
((Button) findViewById(R.id.Ok)).setOnClickListener(new Openabc());
((Button) findViewById(R.id.FindIt)).setOnClickListener(new FindZxingOnclickListener());
}
public class Openabc implements OnClickListener {
public void onClick(View v) {
Intent i = new Intent("android.intent.action.MAIN");
i.addCategory("android.intent.category.LAUNCHER");
i.setPackage("com.3rdparty.app");
startActivity(i);
}}
public class FindZxingOnclickListener implements OnClickListener {
public void onClick(View v) {
Intent marketLaunch = new Intent(Intent.ACTION_VIEW);
marketLaunch.setData(Uri.parse(MARKET_SEARCH_Q_PNAME_ANDRIOS));
startActivity(marketLaunch);
}}
}
一旦你創建的意圖,你打電話'startActivity(意向)',它什麼都不做。 – parkovski