I have the same problem.  I am working on an app that will call a 
pre-entered phone number in case of an emergency. If the user has to 
interact with the app during the emergency, then the purpose of the app is 
defeated.  I am considering implementing my own chooser where the user can 
decide ahead of time which phone app to use.  I haven't worked out all the 
details yet.  Any advice would be appreciated.

On Wednesday, November 27, 2013 at 9:34:27 PM UTC-8, Sinbad wrote:
>
>         
>
> *Target: Call from native dialer only , bypass all dialers.*
>
> This is my method to call from Native Dialer , this method bypass the 
> chooser dialog as I experienced.
>
> Intent i = CallUtils.callfromDefaultDialer(ctxt,dat[1]);
> ctxt.startActivity(i);
>
>
> public static Intent callfromDefaultDialer(Context ctxt, String no) {
>         
>         Intent i = new Intent();
>         i.setAction(Intent.ACTION_CALL);
>         i.setData(Uri.parse("tel:" + no));
>         PackageManager pm = ctxt.getPackageManager();
>         List<ResolveInfo> list = pm.queryIntentActivities(i, 0);
>         for (ResolveInfo info : list) {
>             String pkgnam = info.activityInfo.packageName;
>             if (pkgnam.toLowerCase().equals("com.android.phone")) {
>                 i.setClassName(pkgnam, info.activityInfo.name);
>                 return i;
>             }
>         }
>         
>        return i;
>     }
>
>
> But some time it gives me option to choose . It gives me two dialog two 
> choose, you can see the images in attachment.But second dialog 
> (chooser_win.png) I bypass using above code. but when when i get the first 
> dialog(call_win.png) then the second dialog(chooser_win.png) auto come 
> up(you can say its root of chooser dialog).
>
>
> But using below code I bypass the first dialog (call_win.png). But not 
> second dialog(chooser_win.png)
>
> public static Intent callfromDefaultDialer(Context ctxt, String no) {
>         
>         List<Intent> targetedShareIntents = new ArrayList<Intent>();
>         
>         Intent i = new Intent();
>         i.setAction(Intent.ACTION_CALL);
>         //i.addCategory(Intent.ACTION_DEFAULT);
>         i.setData(Uri.parse("tel:" + no));
>         PackageManager pm = ctxt.getPackageManager();
>         List<ResolveInfo> list = pm.queryIntentActivities(i, 0);
>         for (ResolveInfo info : list) {
>             String pkgnam = info.activityInfo.packageName;
>             Intent targetedShareIntent = new Intent(Intent.ACTION_CALL);
>             if (pkgnam.toLowerCase().equals("com.android.phone")) {
>                 targetedShareIntent.setData(Uri.parse("tel:" + no));
>                 targetedShareIntent.setClassName(pkgnam, 
> info.activityInfo.name);
>                 targetedShareIntents.add(targetedShareIntent);
>                 //return targetedShareIntent;
>                 //i.setClassName(pkgnam, info.activityInfo.name);
>                 //return i;
>             }
>         }
>         
>         Intent chooserIntent = 
> Intent.createChooser(targetedShareIntents.remove(0), "Select app to Call");
>         chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, 
> targetedShareIntents.toArray(new Parcelable[targetedShareIntents.size()]));
>          
>         return chooserIntent;
>     }
>
> I tried this code to get Intent.EXTRA_INITIAL_INTENTS . but not got 
> success. its giving always blank parcelable list.
>
> Intent intent = CallUtils.callfromDefaultDialer(ctxt,dat[1]);
> Parcelable 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/os/Parcelable.java#Parcelable%5B%5D>
> [] pa = intent.getParcelableArrayExtra 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/content/Intent.java#Intent.getParcelableArrayExtra%28java.lang.String%29>
> (Intent 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/content/Intent.java#Intent.0EXTRA_INITIAL_INTENTS>
> .EXTRA_INITIAL_INTENTS 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/content/Intent.java#Intent.0EXTRA_INITIAL_INTENTS>
> );
>
>         Intent 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/content/Intent.java#Intent%5B%5D>[]
>  initialIntents = null;
>
>         if (pa != null) {
>
>             initialIntents = new Intent 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/content/Intent.java#Intent>[pa.length];
>
>             for (int i=0; i<pa.length; i++) {
>
>                 if (!(pa[i] instanceof Intent 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/content/Intent.java#Intent>))
>  {
>
>                     Log.w 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/util/Log.java#Log.w%28java.lang.String%2Cjava.lang.String%29>("ChooseActivity",
>  "Initial intent #" + i
>
>                             + " not an Intent: " + pa[i]);
>
>                 }
>
>                 initialIntents[i] = (Intent 
> <http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/content/Intent.java#Intent>)pa[i];
>
>             }
>
>         }
>
>
> Reference of this Link: 
> http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/com/android/internal/app/ChooserActivity.java
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/c3ea3143-39e6-4265-bd10-cba06f3531b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to