Example usage for android.content Intent getComponent

List of usage examples for android.content Intent getComponent

Introduction

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

Prototype

public @Nullable ComponentName getComponent() 

Source Link

Document

Retrieve the concrete component associated with the intent.

Usage

From source file:cz.maresmar.sfm.plugin.RunPlanReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (ActionContract.BROADCAST_PLAN_RUN.equals(intent.getAction())) {
        int jobId = intent.getIntExtra(ActionContract.EXTRA_JOB_ID, 0);
        Intent intentToPlan = intent.getParcelableExtra(ActionContract.EXTRA_INTENT_TO_DO);
        ComponentName componentName = intentToPlan.getComponent();

        JobIntentService.enqueueWork(context, componentName, jobId, intentToPlan);
    }//w ww. j av a  2s  . c o m
}

From source file:me.xingrz.finder.EntriesActivity.java

protected void overridePendingTransitionForBuiltInViewer(Intent intent) {
    if (intent.getComponent() != null
            && BuildConfig.APPLICATION_ID.equals(intent.getComponent().getPackageName())) {
        overridePendingTransition(R.anim.slide_in, 0);
    }//from   www .  j  a v a2s  . c  o  m
}

From source file:com.android.launcher4.InstallShortcutReceiver.java

static void flushInstallQueue(Context context) {
    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp);
    if (!installQueue.isEmpty()) {
        Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator();
        ArrayList<ItemInfo> addShortcuts = new ArrayList<ItemInfo>();
        int result = INSTALL_SHORTCUT_SUCCESSFUL;
        String duplicateName = "";
        while (iter.hasNext()) {
            final PendingInstallShortcutInfo pendingInfo = iter.next();
            //final Intent data = pendingInfo.data;
            final Intent intent = pendingInfo.launchIntent;
            final String name = pendingInfo.name;

            if (LauncherAppState.isDisableAllApps() && !isValidShortcutLaunchIntent(intent)) {
                if (DBG)
                    Log.d(TAG, "Ignoring shortcut with launchIntent:" + intent);
                continue;
            }// w ww .ja v a  2 s.  co m

            final boolean exists = LauncherModel.shortcutExists(context, name, intent);
            //final boolean allowDuplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);

            // If the intent specifies a package, make sure the package exists
            String packageName = intent.getPackage();
            if (packageName == null) {
                packageName = intent.getComponent() == null ? null : intent.getComponent().getPackageName();
            }
            if (packageName != null && !packageName.isEmpty()) {
                UserHandleCompat myUserHandle = UserHandleCompat.myUserHandle();
                if (!LauncherModel.isValidPackage(context, packageName, myUserHandle)) {
                    if (DBG)
                        Log.d(TAG, "Ignoring shortcut for absent package:" + intent);
                    continue;
                }
            }

            if (!exists) {
                // Generate a shortcut info to add into the model
                ShortcutInfo info = getShortcutInfo(context, pendingInfo.data, pendingInfo.launchIntent);
                addShortcuts.add(info);
            }

        }

        // Notify the user once if we weren't able to place any duplicates
        if (result == INSTALL_SHORTCUT_IS_DUPLICATE) {
            Toast.makeText(context, context.getString(R.string.shortcut_duplicate, duplicateName),
                    Toast.LENGTH_SHORT).show();
        }

        // Add the new apps to the model and bind them
        if (!addShortcuts.isEmpty()) {
            LauncherAppState app = LauncherAppState.getInstance();
            app.getModel().addAndBindAddedWorkspaceApps(context, addShortcuts);
        }
    }
}

From source file:com.example.awesomedogs.ui.MainActivityTest.java

public void testClickingDogOpensDetails() {
    // Clicking on any dog should open the details activity
    ListView listView = getListView();
    listView.performItemClick(null, 0, 0);

    Intent intent = getStartedActivityIntent();
    assertNotNull(intent);//from  www.j  av a2 s . c om
    assertEquals(DogDetailActivity.class.getName(), intent.getComponent().getClassName());
    assertTrue(intent.hasExtra(DogDetailActivity.EXTRA_DOG_ID));
}

From source file:com.liferay.mobile.push.ReceivePushNotificationTest.java

@Test
public void isIntentRegistered() {
    ShadowApplication app = Robolectric.getShadowApplication();

    Intent intent = new Intent("com.google.android.c2dm.intent.RECEIVE");

    List<BroadcastReceiver> receivers = app.getReceiversForIntent(intent);

    Assert.assertEquals(1, receivers.size());

    BroadcastReceiver receiver = receivers.get(0);

    receiver.onReceive(app.getApplicationContext(), intent);

    Intent startedIntent = app.peekNextStartedService();
    String componentClassName = startedIntent.getComponent().getClassName();

    Assert.assertEquals(PushNotificationsService.class.getCanonicalName(), componentClassName);
}

From source file:com.cpd.activities.NewsOpenActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.news_activity_menu, menu);

    MenuItem item = menu.findItem(R.id.action_share);

    ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    shareActionProvider.setShareIntent(getDefaultShareIntent());
    shareActionProvider/*from  w  ww  .  j  a  v  a 2s  . c om*/
            .setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
                @Override
                public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
                    String shareTarget = intent.getComponent().getPackageName();
                    TrackerUtils.shareNewsArticle(mNewsVo.title, shareTarget);

                    return false;
                }
            });

    return super.onCreateOptionsMenu(menu);
}

From source file:com.tasomaniac.android.widget.IntegrationPreference.java

private Intent marketIntent(Intent originalIntent) {
    ComponentName component = originalIntent.getComponent();
    if (component != null) {
        final String packageName = component.getPackageName();
        Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName));
        if (!hasIntent(marketIntent)) {
            marketIntent.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
        }//from  w w w.  j  a v  a  2 s. c om
        if (hasIntent(marketIntent)) {
            return marketIntent;
        }
    }
    return null;
}

From source file:com.doctoror.fuckoffmusicplayer.presentation.base.BaseActivity.java

@Override
public boolean navigateUpTo(final Intent upIntent) {
    ComponentName destInfo = upIntent.getComponent();
    if (destInfo == null) {
        destInfo = upIntent.resolveActivity(getPackageManager());
        if (destInfo == null) {
            return false;
        }//from w  ww. j a v  a 2  s  .c  o  m
    }

    if (shouldUpRecreateTask(upIntent)) {
        startActivity(upIntent);
        finish();
    } else {
        ActivityCompat.finishAfterTransition(this);
    }
    return true;
}

From source file:com.github.jobs.ui.fragment.JobDetailsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    Context themedContext = getActivity().getActionBar().getThemedContext();
    ShareActionProvider shareActionProvider = new ShareActionProvider(themedContext);
    shareActionProvider//from  w w w  .  j  a  v a 2 s  .c  o m
            .setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
                @Override
                public boolean onShareTargetSelected(ShareActionProvider shareActionProvider, Intent intent) {
                    getTracker(getActivity()).trackEvent(CATEGORY_JOBS, ACTION_SHARE,
                            intent.getComponent().getPackageName());
                    return false;
                }
            });
    menu.add(0, SHARE, 0, R.string.share).setActionProvider(shareActionProvider)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(SHARE);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    actionProvider.setShareIntent(ShareHelper.getShareIntent(mJob));
}

From source file:org.rm3l.ddwrt.tiles.status.wireless.WirelessIfaceQrCodeActivity.java

private void setShareFile(File file) {
    if (mShareActionProvider == null) {
        return;/*from w  ww.j  ava2s  .  c  o  m*/
    }

    final Uri uriForFile = FileProvider.getUriForFile(this, "org.rm3l.fileprovider", file);

    mShareActionProvider
            .setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
                @Override
                public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
                    grantUriPermission(intent.getComponent().getPackageName(), uriForFile,
                            Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    return true;
                }
            });

    final Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_STREAM, uriForFile);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, String.format("QR Code for Wireless Network '%s'", mSsid));

    sendIntent.setData(uriForFile);
    sendIntent.setType("image/png");
    sendIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    setShareIntent(sendIntent);

}