Example usage for android.content Intent setPackage

List of usage examples for android.content Intent setPackage

Introduction

In this page you can find the example usage for android.content Intent setPackage.

Prototype

public @NonNull Intent setPackage(@Nullable String packageName) 

Source Link

Document

(Usually optional) Set an explicit application package name that limits the components this Intent will resolve to.

Usage

From source file:com.dwdesign.tweetings.adapter.TabsAdapter.java

@Override
public void onPageReselected(final int position) {
    final String action = mTabs.get(position).cls.getName() + SHUFFIX_SCROLL_TO_TOP;
    final Intent intent = new Intent(action);
    intent.setPackage(mContext.getPackageName());
    mContext.sendBroadcast(intent);/*from w  w w  .j  ava 2  s . com*/
}

From source file:com.dwdesign.tweetings.adapter.TabsAdapter.java

@Override
public boolean onTabLongClick(final int position) {
    final String action = mTabs.get(position).cls.getName() + SHUFFIX_REFRESH_TAB;
    final Intent intent = new Intent(action);
    intent.setPackage(mContext.getPackageName());
    mContext.sendBroadcast(intent);/*from  ww w .  j a v a2 s  .  co  m*/
    return true;
}

From source file:io.v.example.vbeam.vbeamexample.MainActivity.java

@Override
public ListenableFuture<Pair<String, byte[]>> createIntent(VContext context, ServerCall call) {
    String blessing = "anonymous";
    String[] names = VSecurity.getRemoteBlessingNames(ctx, call.security());
    if (names.length > 0) {
        blessing = names[0];/*from  www . j av  a2 s.c  o  m*/
    }
    byte[] payload = ("Hello " + blessing).getBytes(Charset.forName("utf-8"));
    Intent intent = new Intent(this, GotBeamActivity.class);
    intent.setPackage(getApplicationContext().getPackageName());
    System.out.println("APP_SCHEME: " + intent.toUri(Intent.URI_ANDROID_APP_SCHEME));
    System.out.println("INTENT_SCHEME: " + intent.toUri(Intent.URI_INTENT_SCHEME));
    return Futures.immediateFuture(new Pair<>(intent.toUri(Intent.URI_INTENT_SCHEME), payload));
}

From source file:com.commonsware.android.qrck.SyncService.java

private void broadcastStatus() {
    Intent i = new Intent(ACTION_SYNC_STATUS);

    i.setPackage(getPackageName());
    i.putExtra(KEY_STATUS, inProgress.get());

    sendBroadcast(i);//from   w  ww . j a  va2 s  .c o  m
}

From source file:co.uk.gauntface.cordova.plugin.gcmbrowserlaunch.PushNotificationReceiver.java

private void launchBrowserTask(Context context, String url, String packageName) {
    Log.v(C.TAG, "launchBrowserTask");
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    browserIntent.setPackage(packageName);
    browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    List<ResolveInfo> activitiesList = context.getPackageManager().queryIntentActivities(browserIntent, -1);
    if (activitiesList.size() > 0) {
        browserIntent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(browserIntent);
    } else {/*w w  w  .  j a v  a2  s  .c o  m*/
        Intent playStoreIntent = new Intent(Intent.ACTION_VIEW);
        playStoreIntent.setData(Uri.parse("market://details?id=" + packageName));
        playStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(playStoreIntent);
        /**Intent rawIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        rawIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(rawIntent);**/
    }
}

From source file:com.piggate.samples.PiggateLoginService.Service_Notify.java

@Override
public void onTaskRemoved(Intent rootIntent) {
    Intent restartService = new Intent(getApplicationContext(), this.getClass());
    restartService.setPackage(getPackageName());
    PendingIntent restartServicePI = PendingIntent.getService(getApplicationContext(), 1, restartService,
            PendingIntent.FLAG_ONE_SHOT);
    AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePI);
}

From source file:com.figo.campaignhelper.GenerateActivity.java

void doReferrer() {
    Intent i = new Intent("com.android.vending.INSTALL_REFERRER");
    i.setPackage(mPackageName);

    // referrer is a composition of the parameter of the campaign
    i.putExtra("referrer", mReferrer);
    sendBroadcast(i);//from  www .j a  v  a2 s.  co  m

}

From source file:com.android.anton.pushnotificationwithgcm.GCMUtil.MyGcmListenerService.java

@Override
public void onTaskRemoved(Intent rootIntent) {
    Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass());
    restartServiceIntent.setPackage(getPackageName());
    PendingIntent restartServicePendingIntent = PendingIntent.getService(getApplicationContext(), 1,
            restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);

    AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    alarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000,
            restartServicePendingIntent);

    super.onTaskRemoved(rootIntent);
}

From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java

public static void startInAppFlowInApp(Activity activity, W2faInitRequest w2faInitRequest,
        W2faInitResponse w2faInitResponse) {
    Intent intent = new Intent(WibmoSDK.getWibmoIntentActionPackage() + ".InApp");
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra("W2faInitRequest", w2faInitRequest);
    intent.putExtra("W2faInitResponse", w2faInitResponse);

    /*//ww w . j  a v  a 2s  .co  m
    String targetAppPackage = WibmoSDK.getWibmoPackage();
    boolean flag = WibmoSDK.isPackageExisted(activity, targetAppPackage);
    if (flag==false) {
    WibmoSDK.showDownloadDialog(activity);
    }
    */
    if (readyPackage != null) {
        intent.setPackage(readyPackage);
    }

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch

    activity.startActivityForResult(intent, WibmoSDK.REQUEST_CODE_IAP_2FA);
}

From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java

public static void startInAppFlowInApp(Activity activity, WPayInitRequest wPayInitRequest,
        WPayInitResponse wPayInitResponse) {
    Intent intent = new Intent(WibmoSDK.getWibmoIntentActionPackage() + ".InApp");
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra("WPayInitRequest", wPayInitRequest);
    intent.putExtra("WPayInitResponse", wPayInitResponse);

    /*//from   www. j  a  v  a  2  s.  co  m
    String targetAppPackage = WibmoSDK.getWibmoPackage();
    boolean flag = WibmoSDK.isPackageExisted(activity, targetAppPackage);
    if (flag==false) {
    WibmoSDK.showDownloadDialog(activity);
    }
    */
    if (readyPackage != null) {
        intent.setPackage(readyPackage);
    }

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch

    activity.startActivityForResult(intent, WibmoSDK.REQUEST_CODE_IAP_PAY);
}