1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-09-28 02:39:35 +02:00

fix: shortcut to launch urls

This commit is contained in:
chizoba 2017-10-05 17:25:33 +01:00
parent a558a463ef
commit b0bf78dffc
2 changed files with 7 additions and 5 deletions

View file

@ -1161,11 +1161,12 @@ public class MainActivity extends ThemedActivity
case R.id.nav_shortcut: { case R.id.nav_shortcut: {
Intent shortcutIntent = new Intent(MainActivity.this, MainActivity.class); Intent shortcutIntent = new Intent(MainActivity.this, MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.setAction(Intent.ACTION_VIEW);
shortcutIntent.setData(Uri.parse(urls.getStreamUrl()));
// The intent responsible for creating the shortcut // The intent responsible for creating the shortcut
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, _appSettings.getPod().getName());
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(MainActivity.this, R.drawable.ic_launcher)); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(MainActivity.this, R.drawable.ic_launcher));
// To install shortcut // To install shortcut
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");

View file

@ -73,6 +73,10 @@
android:icon="@drawable/ic_cancel_black_48px" android:icon="@drawable/ic_cancel_black_48px"
android:title="@string/action_exit_app" android:title="@string/action_exit_app"
android:visible="false" /> android:visible="false" />
<item
android:id="@+id/nav_shortcut"
android:title="@string/nav_add_shortcut" />
</group> </group>
<group android:checkableBehavior="none"> <group android:checkableBehavior="none">
@ -91,9 +95,6 @@
android:icon="@drawable/ic_info_black_48px" android:icon="@drawable/ic_info_black_48px"
android:title="@string/nav_help_license" /> android:title="@string/nav_help_license" />
<item
android:id="@+id/nav_shortcut"
android:title="@string/nav_add_shortcut" />
</group> </group>
</menu> </menu>