Attempt to launch the supplied {@link Intent}. Queries on-device packages before launching and
will display a simple message if none are available to handle it.
429363
public static boolean maybeStartActivity(Context context, Intent intent) {
        if (hasHandler(context, intent)) {
            context.startActivity(intent);
            return true;
        } else {
            Toast.makeText(context, "There are no applications available to handle this action",
                Toast.LENGTH_LONG).show();
            return false;
        }
    }
663708
public static void navigateToActivity(Context A, Class<?> B, Bundle extras) {
        Intent myIntent = new Intent(A, B);
        myIntent.putExtras(extras);
        A.startActivity(myIntent);
    }
16436
public static void triggerRebirth(Context context, Intent... nextIntents) {
        Intent intent = new Intent(context, ProcessPhoenix.class);
        intent.addFlags(FLAG_ACTIVITY_NEW_TASK); // In case we are called with non-Activity context.
        intent.putParcelableArrayListExtra(KEY_RESTART_INTENTS, new ArrayList<>(Arrays.asList(nextIntents)));
        intent.putExtra(KEY_CLEAR_CACHE, options.shouldClearCache());
        intent.putExtra(KEY_CLEAR_DATA, options.shouldClearData());
        context.startActivity(intent);
        if (context instanceof Activity) {
            ((Activity) context).finish();
        }
        Runtime.getRuntime().exit(0); // Kill kill kill!
    }
793507
protected static void preloadAndLaunch(final Class<? extends Application> appClass, final Class<? extends Preloader> preloaderClass, final String... args) {
        LauncherImpl.launchApplication(appClass, preloaderClass, args);
    }
1075538
public static Intent createStartServiceIntent(
        Context context, String serviceClassName, String intentAction) {
      Intent intent = intentAction != null ? new Intent(intentAction) : new Intent();
      return intent.setClassName(context, serviceClassName);
    }
850185
public void launchSelendroid() {
    launchServer();
    if (config.isGrid()) {
      // Longer timeout to allow for grid registration
      HttpClientUtil.waitForServer(server.getPort(), 3, TimeUnit.MINUTES);
    } else {
      HttpClientUtil.waitForServer(server.getPort(), 20, TimeUnit.SECONDS);
    }
  }
1013666
public static void dump(Intent intent) {
        if (intent == null) {
            QuickUtils.log.v("no intent found");
            return;
        }
        Bundle extras = intent.getExtras();
        QuickUtils.log.v("Intent[@" + Integer.toHexString(intent.hashCode()) + "] content:");
        QuickUtils.log.v("Action   : " + intent.getAction());
        QuickUtils.log.v("Category : " + intent.getCategories());
        QuickUtils.log.v("Data     : " + intent.getDataString());
        QuickUtils.log.v("Component: " + intent.getComponent().getPackageName() + "/" + intent.getComponent().getClassName());
        dumpFlags(intent.getFlags());
        QuickUtils.log.v("HasExtras: " + (extras != null && !extras.isEmpty()));
        dumpExtras(extras);
    }
292479
public Any execute(DeviceImpl device, Any in_any) throws DevFailed
	{

		Util.out4.println("PolledDeviceCmd.execute(): arrived ");

		// Call the device method and return to caller
		return insert(((DServer)(device)).polled_device());
	}
90743
public static void triggerRebirth(Context context, Intent... nextIntents) {
    Intent intent = new Intent(context, ProcessPhoenix.class);
    intent.addFlags(FLAG_ACTIVITY_NEW_TASK); // In case we are called with non-Activity context.
    intent.putParcelableArrayListExtra(KEY_RESTART_INTENTS, new ArrayList<>(Arrays.asList(nextIntents)));
    context.startActivity(intent);
    if (context instanceof Activity) {
      ((Activity) context).finish();
    }
    Runtime.getRuntime().exit(0); // Kill kill kill!
  }
301452
@SuppressWarnings({"unused", "WeakerAccess"})
    public void pushInstallReferrer(Intent intent) {
        try {
            final Bundle extras = intent.getExtras();
            // Preliminary checks
            if (extras == null || !extras.containsKey("referrer")) {
                return;
            }
            final String url;
            try {
                url = URLDecoder.decode(extras.getString("referrer"), "UTF-8");

                getConfigLogger().verbose(getAccountId(), "Referrer received: " + url);
            } catch (Throwable e) {
                // Could not decode
                return;
            }
            if (url == null) {
                return;
            }
            int now = (int) (System.currentTimeMillis() / 1000);

            if (installReferrerMap.containsKey(url) && now - installReferrerMap.get(url) < 10) {
                getConfigLogger().verbose(getAccountId(),"Skipping install referrer due to duplicate within 10 seconds");
                return;
            }

            installReferrerMap.put(url, now);

            Uri uri = Uri.parse("wzrk://track?install=true&" + url);

            pushDeepLink(uri, true);
        } catch (Throwable t) {
            // no-op
        }
    }
402670
@CheckResult public static boolean onNewIntent(@NonNull Intent intent,
      @NonNull Activity activity) {
    //noinspection ConstantConditions
    checkArgument(intent != null, "intent may not be null");
    if (intent.hasExtra(InternalLifecycleIntegration.INTENT_KEY)) {
      InternalLifecycleIntegration.require(activity).onNewIntent(intent);
      return true;
    }
    return false;
  }
1362154
private void startActivity(int requestCode, Context currentContext, Intent intent, Postcard postcard, NavigationCallback callback) {
        if (requestCode >= 0) {  // Need start for result
            if (currentContext instanceof Activity) {
                ActivityCompat.startActivityForResult((Activity) currentContext, intent, requestCode, postcard.getOptionsBundle());
            } else {
                logger.warning(Consts.TAG, "Must use [navigation(activity, ...)] to support [startActivityForResult]");
            }
        } else {
            ActivityCompat.startActivity(currentContext, intent, postcard.getOptionsBundle());
        }

        if ((-1 != postcard.getEnterAnim() && -1 != postcard.getExitAnim()) && currentContext instanceof Activity) {    // Old version.
            ((Activity) currentContext).overridePendingTransition(postcard.getEnterAnim(), postcard.getExitAnim());
        }

        if (null != callback) { // Navigation over.
            callback.onArrival(postcard);
        }
    }
921079
public static void startActivity(Context context, Intent intent,
                                     int requestCode) {
        ThemeManager.startActivity(context, intent, requestCode, null);
    }
680547
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = getIntent();
        if (intent != null) {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                images = extras.getStringArrayList(KEY_IMAGES);
                title = extras.getString(KEY_TITLE);
            }
        }

        setContentView(R.layout.activity_image_gallery);

        bindViews();

        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setTitle(title);
        }

        setUpRecyclerView();
    }
200616
@Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);

        // Verify OAuth callback
        Uri uri = intent.getData();
        if (uri != null && uri.getScheme().equals(OAUTH_CALLBACK_SCHEME)) {
            String verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER);

            new UpworkRetrieveAccessTokenTask().execute(verifier);
        }
    }
147636
public Any execute(DeviceImpl device,Any in_any) throws DevFailed
	{
		Util.out4.println("QueryDeviceCmd.execute(): arrived");

//	
// call DServer method which implements this command
//

		String[] ret = ((DServer)(device)).query_device();

//
// return data to the caller
//

		Any out_any = null;
		//noinspection ErrorNotRethrown
		try
		{
			out_any = Util.instance().get_orb().create_any();
		}
		catch (OutOfMemoryError ex)
		{
			Util.out3.println("Bad allocation while in QueryDeviceCmd::execute()");
			Except.throw_exception("API_MemoryAllocation",
						   "Can't allocate memory in server",
						   "QueryDeviceCmd.execute");
		}
		DevVarStringArrayHelper.insert(out_any,ret);
	
		Util.out4.println("Leaving QueryDeviceCmd.execute()");	
		return	out_any;
	}
591665
private void launchServer() {
    try {
      log.info("Configuring Android SDK");
      if (config.getAndroidHome() != null) {
        AndroidSdk.setAndroidHome(config.getAndroidHome());
      }
      if (config.getAndroidSdkVersion() != null) {
        AndroidSdk.setAndroidSdkVersion(config.getAndroidSdkVersion());
      }
      if (config.getBuildToolsVersion() != null) {
        AndroidSdk.setBuildToolsVersion(config.getBuildToolsVersion());
      }
      if (config.getAvdManager() !=null) {
        AndroidSdk.setAvdManagerHome(config.getAvdManager());
      }
      if (config.getAdbHome() != null) {
        AndroidSdk.setAdbHome(config.getAdbHome());
      }

      log.info("Using Android SDK installed in: " + AndroidSdk.androidHome());
      log.info("Using Android SDK version: " + AndroidSdk.androidSdkFolder().getAbsolutePath());
      log.info("Using build-tools in: " + AndroidSdk.buildToolsFolder().getAbsolutePath());
      log.info("Using adb in: " + AndroidSdk.adb().getAbsolutePath());

      log.info("Starting Selendroid standalone on port " + config.getPort());
      server = new SelendroidStandaloneServer(config);
      server.start();
    } catch (AndroidSdkException e) {
      log.severe("Selendroid standalone was not able to interact with the Android SDK: " + e.getMessage());
      log.severe(
          "Please make sure you have the latest version with the latest updates installed: ");
      log.severe("http://developer.android.com/sdk/index.html");
      throw Throwables.propagate(e);
    } catch (Exception e) {
      log.severe("Error building server: " + e.getMessage());
      throw Throwables.propagate(e);
    }
    Runtime.getRuntime().addShutdownHook(new Thread() {
      public void run() {
        log.info("Shutting down Selendroid standalone");
        stopSelendroid();
      }
    });
  }