Android : Message Intent

前端 未结 5 1883
星月不相逢
星月不相逢 2021-01-12 08:51

I\'m a beginner to android. I need to know is there any intent to open the Create Message window. I tried with this code -

Intent i = new In         


        
相关标签:
5条回答
  • 2021-01-12 09:30

    Try this:

    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_EMAIL  , new String[] { "recipient@example.com" });
    i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
    i.putExtra(Intent.EXTRA_TEXT   , "body of email");
    try {
        startActivity(Intent.createChooser(i, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }
    
    0 讨论(0)
  • 2021-01-12 09:38

    You can just in your xml file add

    android:onClick = "onClick" 
    

    and in activity:

    //main buttons listener
    public void onClick(View view)
    {
        switch (view.getId())
        {
                case R.id.sms:
                Intent intentsms = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + "" ) );
                intentsms.putExtra( "sms_body", "Test text..." );
                startActivity( intentsms );
                break;
        }
    } 
    
    0 讨论(0)
  • 2021-01-12 09:40

    Use just like this for all applications will accept this intent

    case R.id.action_shareapp:
                Intent send = new Intent(Intent.ACTION_SEND);
                send.setType("text/plain");
                send.putExtra(
                        Intent.EXTRA_TEXT,
                        "Checkout this coool App follow this link. https://play.google.com/store/apps/details?id=com.picknget.android");
                startActivity(Intent.createChooser(send, "Share with"));
                break;
    
    0 讨论(0)
  • 2021-01-12 09:41

    This will help you:

    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
    sendIntent.setType("vnd.android-dir/mms-sms");
    startActivity(sendIntent);
    
    0 讨论(0)
  • 2021-01-12 09:44

    I guess this should work:

    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setType("vnd.android-dir/mms-sms");
    
    0 讨论(0)
提交回复
热议问题