我正在尝试编写一个代码来显示应用程序列表,并让用户选择要删除的应用程序。我根据我在网上看到的内容编写了这段代码:
appListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Uri packageUri = Uri.parse(names.get(position));
Intent uninstallIntent =
new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri);
startActivity(uninstallIntent);
}
});
但是,由于某种原因,我收到此异常:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.UNINSTALL_PACKAGE dat=com.ivuu }
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INSTALL_PACKAGES"
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AppList"></activity>
</application>
我对安卓很陌生,我花了一整天的时间在这个......请告诉我我错过了什么
谢谢
您没有方案。Uri
需要采用package:...
格式,其中...
是应用程序 ID/包名称。