我的应用程序中有一个要求,我必须在单击按钮时发送彩信。当我单击按钮时,它会提示选择使用哪个应用程序来完成电子邮件或消息传递操作。我希望它默认通过消息打开。我搜索了很多,但没有得到任何答案。下面,我发布我的代码:
public class MMSActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button mms = (Button)findViewById(R.id.mms);
mms.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
sendMMS();
}
});
}
public void sendMMS() {
Intent in = new Intent(Intent.ACTION_SEND);
in.putExtra("sms_body", "some text");
in.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(Environment.getExternalStorageDirectory()
.getAbsolutePath().toString()+"/diplomat/ALEXANDRA-1339242345022.jpg")));
in.setType("image/jpeg");
startActivity(in);
Log.d("MMS", "SendMMS called");
}
}
我什至尝试将类设置为 android.telephony.SmsMessage 但它没有用。