我有一个应用程序“主人”安装在电话上。是否可以作为即时应用程序从其他应用程序“从”访问资源?
我知道在两个已安装的应用程序之间可以使用:
Resources resources = getPackageManager().getResourcesForApplication(packageName);
String slaveAppName = resources.getString(resources.getIdentifier("app_name", "string", packageName));Thx
L.E :
我还尝试使用以下方法将即时应用程序中的数据发送到安装的应用程序(与上面的相反):
Intent intent = new Intent("com.test.MainActivity");
intent.putExtra("data","data string");
startActivity(intent);在我在AndroidManifest中安装的应用程序上:
<intent-filter>
<action android:name="com.text.MainActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>当我尝试以安装的应用程序发送数据时,一切都很好.但是,一旦我构建了即时的app.....it崩溃:
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.text.MainActivity (has extras) }L.E (2)
我还试着测试,看看手机上安装了多少应用程序,即时应用程序构建使用:
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> pkgAppsList =
this.getPackageManager().queryIntentActivities( mainIntent, 0);
Log.d("log","installed apps : "+pkgAppsList.size());这是一个测试,只是为了找出即时应用程序的构建是否可以“触摸”本地手机设置。而且起作用了
发布于 2018-04-30 21:56:27
即时应用程序可以访问已安装的应用程序的资源
Resources resources = getPackageManager().getResourcesForApplication(packageName); String slaveAppName = resources.getString(resources.getIdentifier("app_name", "string", packageName));代码时,可安装的应用程序是可见的即时。
将以下内容添加到已安装的应用程序中,以使其在即时应用程序中可见:
android:visibleToInstantApps="true"到组件<meta-data android:name="instantapps.clients.allowed" android:value="true"/> to <application>关于如何将已安装的应用程序中的组件公开给即时应用程序?的更多细节
要从安装的应用程序中获取即时应用元数据,请使用LaunchData API
至于将数据从即时发送到已安装的应用程序,在预O设备上,即时应用程序与java.lang.SecurityException: Not allowed to start activity Intent崩溃,这表明即时应用程序不支持它,参见无法从Android即时应用程序启动图库。
https://stackoverflow.com/questions/49926999
复制相似问题