How to open a periscope (Periscope) or any other application from your application?
2 answers
If I understand correctly, then you need to use implicit intents. Check out this: https://developer.android.com/training/basics/intents/sending.html?hl=en https://developer.android.com/guide/components/intents-filters.html
|
Easy way (checking intent on null):
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address"); if (launchIntent != null) { startActivity(launchIntent);//null pointer check in case package name was not found } Option 2: If the application is not found, send it to the market to look for it:
public void startNewActivity(Context context, String packageName) { Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); if (intent == null) { // Bring user to the market or let them choose an app? intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + packageName)); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } |