1 package com.farmerbb.taskbar.activity;
3 import android.app.Activity;
4 import android.content.ActivityNotFoundException;
5 import android.content.Intent;
6 import android.net.Uri;
7 import android.os.Bundle;
9 import com.farmerbb.taskbar.R;
10 import com.farmerbb.taskbar.util.AppEntry;
11 import com.farmerbb.taskbar.util.ApplicationType;
12 import com.farmerbb.taskbar.util.U;
14 public class PersistentShortcutLaunchActivity extends Activity {
17 protected void onCreate(Bundle savedInstanceState) {
18 super.onCreate(savedInstanceState);
20 String packageName = getIntent().getStringExtra("package_name");
21 String componentName = getIntent().getStringExtra("component_name");
22 String windowSize = getIntent().getStringExtra("window_size");
24 if(!U.canDrawOverlays(this) && windowSize != null) {
25 Intent intent = new Intent(this, DummyActivity.class);
26 intent.putExtra("show_permission_dialog", true);
27 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
29 startActivity(intent);
30 } else if(packageName != null && componentName != null) {
31 final AppEntry entry = new AppEntry(packageName, componentName, null, null, false);
33 U.launchApp(this, entry, windowSize, () -> {
34 Intent intent = new Intent(Intent.ACTION_VIEW);
35 intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
38 startActivity(intent, U.getActivityOptionsBundle(this, ApplicationType.APP_PORTRAIT, null));
39 } catch (ActivityNotFoundException | IllegalArgumentException e1) { /* Gracefully fail */ }
42 U.showToast(this, R.string.tb_invalid_shortcut);