0
如何在android中使用小部件發送電子郵件?在我onUpdate()
方法我已經寫了以下內容:android,發送電子郵件,部件
Intent intent3 = new Intent(Intent.ACTION_SEND);
intent3.setData(Uri.parse("mailto:"));
intent3.setType("text/plain");
intent3.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
intent3.putExtra(Intent.EXTRA_SUBJECT,"Temat");
intent3.putExtra(Intent.EXTRA_TEXT, "Tekst wiadomości");
PendingIntent pendingEmailIntent = PendingIntent.getActivity(context,0,intent3,0);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.widget_layout);
remoteViews.setOnClickPendingIntent(R.id.email_button,pendingEmailIntent);
其他操作,如打開新的活動或瀏覽器,工作爲疑似,但是這一次不是。我究竟做錯了什麼?
:''Uri',使用'ACTION_SENDTO',不'ACTION_SEND'
然後,我已經改變了我的代碼。 – CommonsWare
我已經改變了那個,但仍然沒有工作。 –
檢查LogCat,看看是否有堆棧跟蹤或其他消息,可能在警告嚴重性。例如,您可能需要將'FLAG_ACTIVITY_NEW_TASK'添加到'Intent',並且這應該顯示在LogCat中。 – CommonsWare