How to open and show phone's message inbox programmatically..?

前端 未结 4 791
一生所求
一生所求 2021-01-26 23:19

When we click on messages we are showed with the inbox.

I want to show the same window when i clicked on my application\'s button.

So, I want to start message in

相关标签:
4条回答
  • 2021-01-26 23:49
    String SMS_MIME_TYPE = "vnd.android-dir/mms-sms";
    
            Intent defineIntent = new Intent(Intent.ACTION_MAIN);                
    
            defineIntent.setType(SMS_MIME_TYPE);                
    
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0 , defineIntent, 0);
    

    Not sure whether it works or not

    0 讨论(0)
  • 2021-01-26 23:55

    Try this.. works perfectly..!

    public void openInbox() {
    String application_name = "com.android.mms";
    try {
    Intent intent = new Intent("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.LAUNCHER");
    
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    List<ResolveInfo> resolveinfo_list = this.getPackageManager()
    .queryIntentActivities(intent, 0);
    
    for (ResolveInfo info : resolveinfo_list) {
    if (info.activityInfo.packageName
    .equalsIgnoreCase(application_name)) {
    launchComponent(info.activityInfo.packageName,
    info.activityInfo.name);
    break;
    }
    }
    } catch (ActivityNotFoundException e) {
    Toast.makeText(
    this.getApplicationContext(),
    "There was a problem loading the application: "
    + application_name, Toast.LENGTH_SHORT).show();
    }
    }
    
    private void launchComponent(String packageName, String name) {
    Intent launch_intent = new Intent("android.intent.action.MAIN");
    launch_intent.addCategory("android.intent.category.LAUNCHER");
    launch_intent.setComponent(new ComponentName(packageName, name));
    launch_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    this.startActivity(launch_intent);
    }
    
    0 讨论(0)
  • 2021-01-27 00:05

    I extended srinivasa's solution above to get the package name of the default SMS app currently being used on the device:

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            application_name = Telephony.Sms.getDefaultSmsPackage(this);
        }
    

    I found this worked well across Samsung and Nokia devices which both use a different app for SMS out of the box.

    0 讨论(0)
  • 2021-01-27 00:06

    SMS content provider will give you the all sms related data . the Screen you are talking about is implemented by manufacturer using that data . so you have two choices to achieve this :

    1) Use cursor returned by related content provider and create your own screen with desired look and feel .

    2) get Information about package name of message screen for diffrent manufacures (like suppose samsung have com.samsung.smsscreeen ) and lauch intent for this class name . write case statements for devices you want to add.

    0 讨论(0)
提交回复
热议问题