Tag: android intent

如何从通知单击发送参数到活动?

我可以find一种方法来从我的通知中发送参数给我的活动。 我有一个创build通知的服务。 当用户点击通知时,我想用一些特殊的参数打开我的主要活动。 例如一个项目ID,所以我的活动可以加载并呈现一个特殊的项目详细信息视图。 更具体地说,我正在下载一个文件,当文件被下载的时候,我想让这个通知有一个意图,当点击它时,它会以特殊模式打开我的活动。 我曾尝试在我的意图上使用putExtra ,但似乎不能提取它,所以我认为我做错了。 创build通知的服务中的代码: // construct the Notification object. final Notification notif = new Notification(R.drawable.icon, tickerText, System.currentTimeMillis()); final RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.custom_notification_layout); contentView.setImageViewResource(R.id.image, R.drawable.icon); contentView.setTextViewText(R.id.text, tickerText); contentView.setProgressBar(R.id.progress,100,0, false); notif.contentView = contentView; Intent notificationIntent = new Intent(context, Main.class); notificationIntent.putExtra("item_id", "1001"); // <– HERE I PUT THE EXTRA VALUE PendingIntent contentIntent […]

“为此应用评分” – 在手机上的Google Play商店应用中链接

我想在Android应用中添加一个“评价此应用” – 链接,以在其手机上打开用户的Google Play商店应用中的应用列表。 我需要编写什么样的代码才能在电话上的Google Play商店应用中打开market://或http://链接? 你把代码放在哪里? 有没有人有这样的示例实现? 你是否必须指定market://或http://链接将被放置的屏幕,哪个是最好用的 – market://或http:// ?

列出一个意图的所有附加

出于debugging的原因,我想列出一个意图的所有额外(和他们的价值观)。 现在,获得钥匙不是问题 Set<String> keys = intent.getExtras().keySet(); 但获取键的值是一个对我来说,因为一些值是string,一些是布尔值…我怎么能得到一个循环中的值(循环通过键),并将值写入日志文件? 感谢任何提示!

Android的意图是什么?

Android的意图是什么? 有人可以用一个例子来详细说明吗? 意图的types是什么,以及我们为什么使用它们? 为什么intents在Android中如此重要?

如何将URI传递给intent?

我试图传递一个URI对象到我的意图,以便在另一个活动中使用该URI … 我如何传递一个URI? private Uri imageUri; …. Intent intent = new Intent(this, GoogleActivity.class); intent.putExtra("imageUri", imageUri); startActivity(intent); this.finish(); 我如何在我的其他活动中使用此URI? imageUri = extras.getString("imageUri"); // I know thats wrong … 感谢你们

使用新的Google相册应用程序select照片已损坏

我的应用程序能够从库中select照片。 正是我想从这个select的文件path。 这是创buildselect照片的意图的代码: Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, INTENT_REQUEST_CODE_SELECT_PHOTO); 这是从URI获取文件path的代码: Cursor cursor = null; String path = null; try { String[] projection = { MediaStore.Images.Media.DATA }; cursor = context.getContentResolver().query(contentUri, projection, null, null, null); int columnIndex = cursor.getColumnIndexOrThrow(projection[0]); cursor.moveToFirst(); path = cursor.getString(columnIndex); } finally { if (cursor != null) { cursor.close(); } } […]

如何将图像从drawable添加到gmail?

我试图从我的GridView的图像附加到Gmail或Facebook,但每当我试图附加我的应用程序崩溃,我得到以下错误与nullpointerexception,下面是我的代码与gridview图像select,任何一个可以帮助吗? public class Free_Cover_Activity extends AppCompatActivity { GridView grid; int[] imageId = { R.drawable.discovercover, R.drawable.burpresswordfree, R.drawable.flyfree, R.drawable.cantmovefree, R.drawable.cantmovewordfree, R.drawable.chalkthisfree, R.drawable.fivehundredmetersfree, R.drawable.freeexercise, R.drawable.gym_smilie, R.drawable.hundredcalrairesfree, R.drawable.injuryfree, R.drawable.jumpropefree, R.drawable.nicesnathcfree, R.drawable.personglrecordfree, R.drawable.posefree, R.drawable.pushupfree, R.drawable.shoulder, R.drawable.timewordfree, R.drawable.unbrokernfree, R.drawable.weightbeltfree }; private Bitmap mBitmap; private Intent email; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.free_cover_gridview); android.support.v7.app.ActionBar abar = getSupportActionBar(); ColorDrawable colorDrawable = […]

Android L(API 21) – java.lang.IllegalArgumentException:Service Intent必须是显式的

Android新版本 – “Lollipop”(API 21)带来了不less变化,但是如果您希望将应用程序定位到该API,则会带来一些价格。 当我们开始将我们的应用程序调整到新的API时,我们遇到的第一个问题是IllegalArgumentException: Service Intent must be explicit 如果你遇到了这个问题,而且你实际上打算以明确的方式使用你的意图(这意味着当启动这个服务的时候,你只需要执行一个服务动作),下面是一个快速修复的例子, public static Intent createExplicitFromImplicitIntent(Context context, Intent implicitIntent) { // Retrieve all services that can match the given intent PackageManager pm = context.getPackageManager(); List<ResolveInfo> resolveInfo = pm.queryIntentServices(implicitIntent, 0); // Make sure only one match was found if (resolveInfo == null || resolveInfo.size() != 1) { […]

如何从AsyncTask中的onPostExecute发回数据?

我的问题是相同的这个实例variables的活动没有在AsyncTask onPostExecute中设置或如何从AsyncTask返回到主UI线程的数据,但我想发回数据回到相同的调用活动。 不意图的startActivity始终重新启动活动

我怎样才能打开Android浏览器指定的POST参数?

我的应用程序,我需要在Android浏览器中打开一个链接。 这个页面只能通过POST获得一些数据。 我可以将这些参数(数据)添加到启动浏览器的意图吗? 你知道这是可能的吗? 如果是的话,你能给我一个提示吗?