Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 尝试发送SMS消息会出现“使用完成操作”对话框,但消息应用程序不在列表中?_Android_Sms_Android Widget - Fatal编程技术网

Android 尝试发送SMS消息会出现“使用完成操作”对话框,但消息应用程序不在列表中?

Android 尝试发送SMS消息会出现“使用完成操作”对话框,但消息应用程序不在列表中?,android,sms,android-widget,Android,Sms,Android Widget,我正在尝试发送打开消息应用程序以从小部件启动sms消息,但当我启动活动时,我会看到一个包含一长串应用程序的完整操作对话框,但我没有看到我认为应该是尝试发送sms消息的默认消息应用程序 这是我的密码: public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Intent sendIntent = new Intent(Intent.ACTION_V

我正在尝试发送打开消息应用程序以从小部件启动sms消息,但当我启动活动时,我会看到一个包含一长串应用程序的完整操作对话框,但我没有看到我认为应该是尝试发送sms消息的默认消息应用程序

这是我的密码:

public void onUpdate(Context context,
     AppWidgetManager appWidgetManager, int[] appWidgetIds) {

   Intent sendIntent = new Intent(Intent.ACTION_VIEW);
   PendingIntent smsIntent1 = PendingIntent.getActivity(context, 0, sendIntent, 0);
   sendIntent.putExtra("address", "8017777777");
   sendIntent.setType("vnd.android-dir/mms-sms");
   views.setOnClickPendingIntent(R.id.sms_btn1, smsIntent1);

   appWidgetManager.updateAppWidget(appWidgetIds, views); 
  super.onUpdate(context, appWidgetManager, appWidgetIds); 
}

我的舱单上写着:

<uses-permission android:name="android.permission.SEND_SMS"/>

有什么想法吗?谢谢

最有可能的是,Messenger应用程序具有不包含您的MIME类型的

我不完全确定你为什么会有那种MIME类型。我也不清楚整个意图是否会起作用。我知道这是可行的,假设801777是一个电话号码:

Intent sms=new Intent(Intent.ACTION_SENDTO, Uri.parse("tel:8017777777"));

sms.putExtra("sms_body", msg.getText().toString());

startActivity(sms);
请注意,在这种情况下,您不需要SEND_SMS权限。仅当您使用SmsManager直接发送SMS时,才需要此功能


这演示了上面的Intent语法,以及直接使用smsmsmanager作为如何向联系人列表中的联系人发送文本消息的选项。

我尝试了Commonware所说的方法,但没有奏效,但它使我走上了正确的轨道,即使用Intent.ACTION\u SENDTO。我在这里找到了我需要的:

结果是这样的:

Uri uri = Uri.parse("smsto:0800000123");   
   Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
   it.putExtra("sms_body", "The SMS text");   
   PendingIntent smsIntent1 = PendingIntent.getActivity(context, 0, it, 0);
   views.setOnClickPendingIntent(R.id.sms_btn1, smsIntent1);

我试过了,但点击按钮后什么也没发生。我想知道是否有一些问题,因为它是一个小部件?Intent sms=newintentintent.ACTION_SENDTO,Uri.parsetel:80177777;sms.putExtrasms_body,body;PendingEvent SMSinent1=PendingEvent.getActivitycontext,0,sms,0;views.setOnClickPendingIntentR.id.sms_btn1,smsinent1;对不起,我的计划错了。我总是忘记SENDTO使用smsto。