jestem tutaj wykonującego demo dla Androida Skróty wprowadza w android nugat App ShortcutsAktualizacja Android SDK: zainstalować najnowszą platformę do wprowadzania nowych interfejsów API, takich jak „ShortcutManager”
Użyłem następujący kod do tworzenia aplikacji skrót
ShortcutManager shortcutManager;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
shortcutManager = getSystemService(ShortcutManager.class);
ShortcutInfo shortcut;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
shortcut = new ShortcutInfo.Builder(this, "second_shortcut")
.setShortLabel(getString(R.string.str_shortcut_two))
.setLongLabel(getString(R.string.str_shortcut_two_desc))
.setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
.setIntent(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.google.co.in")))
.build();
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
}
}
Ale tutaj otrzymuję czas kompilacji błądcannot resolve symbol ShortcutManager
.
Oto mój plik build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
...
minSdkVersion 9
targetSdkVersion 24
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
}
Skróty aplikacji zostały wprowadzone w API 25+. Nie są jeszcze częścią biblioteki wsparcia. –