How to start and App Chooser

前端 未结 5 1032
春和景丽
春和景丽 2021-01-13 07:09

The task of this application is to implicitly activate a separate application to view the URL, “http:// www.google.com”. So, App Chooser should appear and let me choose betw

5条回答
  •  无人及你
    2021-01-13 07:38

    Easy implementation of multiple actions app chooser:

    Intent phoneCall = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", contactNumber, null));
    // Intent sms = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + contactNumber));
    Intent whatsapp = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + contactNumber));
    Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
    builder.appendPath("time");
    ContentUris.appendId(builder, Calendar.getInstance().getTimeInMillis());
    Intent calendarIntent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
    
    Intent chooser = Intent.createChooser(whatsapp, "chooser??"); // default action
    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{phoneCall, calendarIntent}); // additional actions
    startActivity(chooser);
    

提交回复
热议问题