這裏就是我想要實現: 小部件3個按鈕: 1.查看文件夾 2.添加項目 3.添加項目,並啓動相機中的照片附加到項目。Android小工具和兩個不同的PendingIntents
我希望通過使用額外的意圖,達到2 & 3,只需添加一個布爾額外的「照片」,如果被點擊3號鍵是成立的,這裏是我的代碼:
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setData(Uri.parse("content://"
+ NoteProviderMetaData.AUTHORITY + "/folders/"
+ folderId));
intent.putExtra("photo", false);
intent.putExtra("kind", "NO PHOTO");
intent.setAction(Intent.ACTION_INSERT);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
views.setOnClickPendingIntent(R.id.imageButton2, pendingIntent);
Intent intentFolder = new Intent(Intent.ACTION_VIEW);
intentFolder.setData(Uri.parse("content://"
+ NoteProviderMetaData.AUTHORITY + "/folders/"
+ folderId + "/notes"));
PendingIntent pendingIntentFolder = PendingIntent.getActivity(this, 0, intentFolder, 0);
Intent intentPhoto = new Intent(Intent.ACTION_INSERT);
intentPhoto.setData(Uri.parse("content://"
+ NoteProviderMetaData.AUTHORITY + "/folders/"
+ folderId));
intentPhoto.putExtra("photo", true);
intentPhoto.putExtra("kind", "PHOTO");
intentPhoto.setAction(Intent.ACTION_INSERT);
PendingIntent pendingIntentPhoto = PendingIntent.getActivity(this, 0, intentPhoto, 0);
views.setOnClickPendingIntent(R.id.imageButton3, pendingIntentPhoto);
問題是在創建pendingIntentPhoto
之後立即生成的,我的pendingIntent
附加項被新值覆蓋,並且我總是在我的活動中獲得true
和PHOTO
值。 pendingFolder
意圖的作品,所以我想它會很好,只是使用另一個意圖行動,但我想了解這個PendingIntent的事情是如何工作的。
是的,這也適用於我,謝謝你的提示。 – kcoppock