这是我的代码
private Button emailBtn;/* button object
private Button smsBtn; */
smsBtn = (Button) findViewById(R.id.msg_btn);*/ layout
.getLaunchIntentForPackage("com.google.android.gm");
startActivity(LaunchIntent);
}
});
smsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent LaunchIntent = getPackageManager()
.getLaunchIntentForPackage("com.android.sms");
startActivity(LaunchIntent);
}
});
}
}
答案 0 :(得分:0)
onClick
该按钮的事件。它将打开默认的短信应用程序
smsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);
}
});
答案 1 :(得分:0)
您可以在按钮点击事件上实现此代码。
Intent n = new Intent(Intent.ACTION_VIEW);
n.setType("vnd.android-dir/mms-sms");
n.putExtra("address", "1234567890");
n.putExtra("sms_body","Hello EveryBody!!!");
startActivity(n);
答案 2 :(得分:0)
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);
答案 3 :(得分:0)
PFA是打开消息应用程序(Kotlin)的最新解决方案:
val sendIntent = Intent(Intent.ACTION_VIEW)
sendIntent.data = Uri.parse("sms:"+issue.number)
mContext.startActivity(sendIntent)