2

I have a question related to choosing an application programmatically when shown the dialog "Complete Action Using" in Android.

An example would be as follows: In my code, I have this statement:

startActivity(new Intent(Intent.ACTION_VIEW,
                         Uri.parse("http://www.youtube.com/watch?v=98yl260nMEA")));

I will then be shown a dialog box with two options: to complete the action using the Browser or YouTube

Any idea how can I choose YouTube without being shown the dialog box?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Nicholas Key
  • 1,429
  • 4
  • 21
  • 24
  • Have you found solution for this? – keen Jun 05 '14 at 06:20
  • 1
    Does this answer your question? [Android Eliminate Complete Action Using dialog](https://stackoverflow.com/questions/3082077/android-eliminate-complete-action-using-dialog) – Tomerikoo Apr 23 '21 at 22:08
  • @Tomerikoo That seems to be a different situation, where they're trying to launch a component of their **own** app. Note that the answer suggests modifying the intent filters: they can't well modify the intent filters of YouTube or their browser. – Ryan M Apr 24 '21 at 10:06

2 Answers2

0

I think you will need more information about the intent-filter of the app you want to launch by default (in this case youtube app). That target app might have multiple intent-filters and one of them might be more specific. You can call startActivity with that specific intent, and then the intended app will be launched directly. However, this requires you to have more knowledge of the target app (which is difficult in most cases like Youtube app).

Other than that, I don't think you can do much from within your app. Intent resolution is done by the Android framework, so if a user app could override it somehow, that would be a flaw in terms of security.

Jayesh
  • 51,787
  • 22
  • 76
  • 99
  • hmm ... makes some sense. thanks, Jayesh. I have this code (but it only shows me the suggested apps to use - in this case, the Browser and YouTube) PackageManager pm = getPackageManager(); List activities = pm.queryIntentActivities(new Intent(Intent.ACTION_VIEW, Uri.parse(http://www.youtube.com/watch?v=Zi_XLOBDo_Y)), 0); Iterator actList = activities.iterator(); while(actList.hasNext()) { ResolveInfo curr = actList.next(); Log.d("Intents =====> ", curr.toString() + " " + curr.match + " " + curr.isDefault); } – Nicholas Key Dec 08 '09 at 19:54
0
PackageManager pm = getPackageManager(); 
List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(Intent.ACTION_VIEW, Uri.parse(youtube.com/watch?v=Zi_XLOBDo_Y)), 0); 
Iterator<ResolveInfo> actList = activities.iterator(); 
while(actList.hasNext()) { 
   ResolveInfo curr = actList.next(); 
   Log.d("Intents =====> ", curr.toString() + " " + curr.match + " " + curr.isDefault); 
}
Nicholas Key
  • 1,429
  • 4
  • 21
  • 24