Tag: android intent

从Android应用程序安装程序和主屏幕启动应用程序时的活动堆栈sorting问题

仅用于testing目的,我允许我的应用APK通过URL下载和安装。 一旦在手机上下载,就可以通过Android应用程序安装程序启动,该应用程序安装程序可以让用户select将其安装到设备上,然后运行。 考虑我们是否按照上述方式下载并运行了应用程序。 我的应用程序中的主/启动器活动是一个login页面( Activity A )。 一旦用户被authentication,他们被带到应用程序的主要区域,例如Activity B 所以现在这个任务的当前活动堆栈是A > B 然后按手机上的主页button,然后进入Android主屏幕。 我通过菜单中的图标重新启动我的应用程序,并将其带到Activity A而不是Activity B 活动堆栈现在是A > B > A ,或者现在有两个单独的任务,分别是活动堆栈A > B和A 当我重新启动应用程序时,我想要返回到Activity B 在这种状态下按回来将带我回到Activity B 这种不希望的行为只发生在我通过安装程序打开应用程序时,而不是通过主屏幕/菜单打开应用程序。 我研究了各种机制如何开展活动。 当我们使用应用程序安装程序时,我们看到以下日志: INFO/ActivityManager(XXXX): Starting activity: Intent { dat=file:///mnt/sdcard/download/[my app].apk cmp=com.android.packageinstaller/.InstallAppProgress (has extras) } INFO/ActivityManager(XXXX): Starting activity: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=[my package]/[Activity A] } 通过启动器/主屏幕: INFO/ActivityManager(XXXX): […]

Android中的sharedUserId是什么,它是如何使用的?

我在sharedUserID困惑。什么是使用sharedUserId?如何使用?在Android中使用?

Android中的多种MIMEtypes

有没有办法使用intent.setType()并提供多种types(如图像和video)? 我正在使用ACTION_GET_CONTENT 。 它似乎只用逗号分隔的types工作。

android渐变中的angular度属性

我正在通过testing的例子。 在某些Image背景中,他们使用渐变,代码就像这样 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#ff0000" android:centerColor="#00ff00" android:endColor="#0000ff" android:angle="180"/> <corners android:radius="5dp" /> </shape> 在上面的XML我没有得到angle属性。 但是当我稍微改变angle的价值模式偏斜。 任何一个可以解释我如何工作……….. 🙂

有exception:片段已经激活

我有一个片段 ; MyFragment myFrag = new MyFragment(); 我把bundle数据放到这个片段中: Bundle bundle = new Bundle(); bundle.putString("TEST", "test"); myFrag.setArguments(bundle); 然后,我用这个replace旧的碎片,并放在后台 : //replace old fragment fragmentTransaction.replace(R.id.fragment_placeholder, myFrag, "MyTag"); //put on backstack fragmentTransaction.addToBackStack(null); //commit & get transaction ID int transId = fragmentTransaction.commit(); 后来,我用上面的事务ID( transId ) popupbackstack : //pop the transaction from backstack fragmentManager.popBackStack(transId,FragmentManager.POP_BACK_STACK_INCLUSIVE); 后来,我再次将bundle数据设置为我的片段( myFrag )的参数: //Got Java.lang.IllegalStateException: fragment already […]

有什么办法从偏好向额外的意图?

嗨,我从偏好屏幕启动活动。 活动由三个偏好共享。 我不知道我是否可以在xml中为这个活动设置额外的 <Preference android:key="action_1" android:title="@string/action_1_title" > <intent android:action="com.package.SHAREDACTION" > </intent> </Preference> 我不知道我能不能做点什么 <extras> <item android:name="" android:value=""/> </extras> 我所需要做的只是传递一个整数。 我可以采取不同的行动,并检查行动,而不是额外的。

Android:从preferences.xml开始活动

我想从默认的preferences.xml中使用<intent>标签来启动一个Activity。 活动经过了充分的testing,问题不在于此。 (我在我的应用程序中扩展PreferenceActivity,所以preferences.xml是“随”而来)请看代码,怎么了? 的preferences.xml: …. <PreferenceCategory android:title="@string/titleEtcSetup"> <PreferenceScreen android:key="renameCourses" android:title="@string/titleRenameCourses" android:summary="@string/textRenameDisplayedCoursesNames"> <intent android:action="android.intent.action.VIEW" android:targetPackage="my.notifier.ui" android:targetClass="my.notifier.ui.EditCoursesNamesActivity" /> </PreferenceScreen> ….. </PreferenceCategory> ….. manifest.xml文件: …. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.notifier.ui"…. …. <activity android:name=".EditCoursesNamesActivity" android:label="@string/titleRenameCourses"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> ….. 当我按下“renameCourses项目”时Activity没有调用,没有任何反应。 LogCat是“清除”,没有错误或警告。 我search了很多,我没有find解决办法,也许我只是错过了一些东西…请帮助!

从Picasa // Google +同步文件夹中获取图片库中的图片不起作用

我正在尝试从Google+已同步的照片中的一个文件夹中获取图库应用中的图片。 select图像后,Uri被正确传回。 但是,当我尝试在存储设备上获取该映像的实际path时,我可以使用它,它会崩溃。 这个问题似乎是与picasa内容提供商专门有关的。 testingNexus S和Nexus 7以及其他设备。 E / AndroidRuntime(14572):java.lang.RuntimeException:传递结果失败ResultInfo {who = null,request = 1,result = -1,data = Intent {dat = content://com.google.android.gallery3d.provider / picasa / item / 5427003652908228690}} 在这里,dat字段似乎正确地通过了Uri,但是当我尝试获取图像的位置时,它会崩溃,并出现以下错误。 W / GalleryProvider(14381):不支持的列:_data 似乎Picasa相册的内容提供商没有_data字段。 获取位置的代码是: // imageUri是上面的Uri。 String [] proj = {MediaStore.Images.Media.DATA}; Cursor cursor = context.getContentResolver()。query(imageUri,proj,null,null,null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String filePath = cursor.getString(column_index); cursor.close(); […]

Android意图用附件发送电子邮件

可能重复: 从内部存储电子邮件 电子邮件正在收件人收到,但没有附件。 这里是代码,任何专家知道我哪里错了? Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"email@example.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, "subject here"); intent.putExtra(Intent.EXTRA_TEXT, "body text"); File root = Environment.getExternalStorageDirectory(); File file = new File(root, xmlFilename); if (!file.exists() || !file.canRead()) { Toast.makeText(this, "Attachment Error", Toast.LENGTH_SHORT).show(); finish(); return; } Uri uri = Uri.parse("file://" + file); intent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(intent, "Send email…")); 我没有得到任何敬酒信息。 谢谢。

在Android中使用Bundle代替直接Intent putExtra()的优点

在我的android应用程序中,我总是使用Intent类的putExtra()函数将任意数量的值传递给新的Activity 。 喜欢这个: Intent i = new Intent(this, MyActivity.class); i.putExtra(ID_EXTRA1, "1"); i.putExtra(ID_EXTRA2, "111"); startActivity(i); 我知道Android中的Bundle ,我也看到有人使用Bundle将值传递给新的Activity 。 喜欢这个: Intent intent = new Intent(this, MyActivity.class); Bundle extras = new Bundle(); extras.putString("EXTRA_USERNAME","my_username"); extras.putString("EXTRA_PASSWORD","my_password"); intent.putExtras(extras); startActivity(intent); 这里我有2个疑问。 为什么我应该使用Bundle如果我可以通过将值直接传递给Intent来将值传递给新的Activity ? 使用Bundle而不是直接的Intent putExtra()什么putExtra() ?