简体   繁体   中英

The app wasn't found in the list of installed apps

I was trying to open the Notifications Settings screen on a button click in my app but I get an error toast message saying

The app wasn't found in the list of installed apps

I was following the Android training documents and double checked my package name but I'm not sure why I can't get it to work.

val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).apply {
                    putExtra(Settings.EXTRA_APP_PACKAGE, "com.xyz.abc")
                    putExtra(Settings.EXTRA_CHANNEL_ID, "com.xyz.abc.SomeUniqueString")
                }
                startActivity(intent)

Get your package name programatically, no need to write packagename hardcoded. Get like this:

String packageName=getApplicationContext().getPackageName()

You can also check this app is installed or not:

 List<PackageInfo> apps = getPackageManager().getInstalledPackages(0);
    for(PackageInfo packageInfo:apps){
    if(packageInfo.packageName.equals(packageName)){
//app is installed. do whatever you want
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM