Intent setComponent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent setComponent method.

This code example shows how to use the following methods: toString, setComponent
	public void onReceive(Context context, Intent intent) {
		// just make sure we are getting the right intent (better safe than sorry) 
		//String itclass = intent.get("intentclass"); 
		if ( "android.intent.action.BOOT_COMPLETED".equals(intent.getAction()) ||
				intent.getBooleanExtra("ThisIntentIsTPStartUpClass",false) ) {
			ComponentName comp = new ComponentName(context.getPackageName(), PingService.class.getName());
			ComponentName service = context.startService(new Intent().setComponent(comp));
			if (null == service){
				// something really wrong here 
				Log.e(TAG, "Could not start service " + comp.toString());
			} 
		} else { 
			Log.e(TAG, "Received unexpected intent " + intent.getAction());   
		} 
	} 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setComponent
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setComponent
 
    return(super.onOptionsItemSelected(item));
  } 
 
  private void refreshPlugin() { 
    Intent call=new Intent(ACTION_CALL_FOR_CONTENT);
 
    call.setComponent(pluginCN);
    sendBroadcast(call);
  } 
 
  private BroadcastReceiver plugin=new BroadcastReceiver() {
    @Override 
    public void onReceive(Context ctxt, Intent i) { 
      if (ACTION_REGISTER_PLUGIN.equals(i.getAction())) { 
        pluginCN=(ComponentName)i.getParcelableExtra(EXTRA_COMPONENT); 
      } 
      else if (ACTION_DELIVER_CONTENT.equals(i.getAction())) { 
        RemoteViews rv=(RemoteViews)i.getParcelableExtra(EXTRA_CONTENT); 
        ViewGroup frame=(ViewGroup)findViewById(android.R.id.content); 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setComponent
     * Checks whether the global search provider with a given 
     * component name is installed on the system or not. This deals with 
     * cases such as the removal of an installed provider. 
     */ 
    private boolean isInstalled(ComponentName globalSearch) {
        Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
        intent.setComponent(globalSearch);
 
        List<ResolveInfo> activities = queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        if (activities != null && !activities.isEmpty()) {
            return true; 
        } 
 
        return false; 
    } 
 
    private static final Comparator<ResolveInfo> GLOBAL_SEARCH_RANKER =
            new Comparator<ResolveInfo>() { 
        @Override 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addCategory, setComponent
        startActivity(intent);
    } 
 
    @Override 
    public boolean onLongClick(View v) {
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.setComponent(ComponentName
                .unflattenFromString("com.aokp.romcontrol/.ROMControlActivity"));
        intent.addCategory("android.intent.category.LAUNCHER");
 
        startActivity(intent);
        return super.onLongClick(v);
    } 
 
} 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setComponent
    public IBinder onBind(Intent intent) {
        return null; 
    } 
 
    public static void stop(Context context) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(
                "com.android.cts.usespermissiondiffcertapp", 
                "com.android.cts.usespermissiondiffcertapp.ReceiveUriService")); 
        context.stopService(intent);
    } 
 
    public static int getCurStartId() { 
        synchronized (sLock) {
            return sCurStartId;
        } 
    } 
 
    public static void stopCurWithId(int id) {
        synchronized (sLock) {
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addFlags, putExtra, setComponent, setData
        String query = cursor.getSuggestionQuery();
        String userQuery = cursor.getUserQuery();
        String extraData = cursor.getSuggestionIntentExtraData();
 
        // Now build the Intent 
        Intent intent = new Intent(action);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // We need CLEAR_TOP to avoid reusing an old task that has other activities 
        // on top of the one we want. 
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (data != null) {
            intent.setData(Uri.parse(data));
        } 
        intent.putExtra(SearchManager.USER_QUERY, userQuery);
        if (query != null) {
            intent.putExtra(SearchManager.QUERY, query);
        } 
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        } 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: putExtras, setComponent, setFlags
         * binding any matching widgets to the corresponding targets. We can't 
         * bind ourselves because our parent process can't obtain the 
         * BIND_APPWIDGET permission. 
         */ 
        private void launchAppWidgetBinder(int[] bindSources, ArrayList<ComponentName> bindTargets) {
            final Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.android.settings",
                    "com.android.settings.LauncherAppWidgetBinder")); 
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             
            final Bundle extras = new Bundle();
            extras.putIntArray(EXTRA_BIND_SOURCES, bindSources);
            extras.putParcelableArrayList(EXTRA_BIND_TARGETS, bindTargets);
            intent.putExtras(extras);
             
            mContext.startActivity(intent);
        } 
         
        /** 
         * Loads the default set of favorite packages from an xml file. 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setComponent
    } 
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        ActivityInfo info = (ActivityInfo) l.getItemAtPosition(position);
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(this, info.name));
        startActivity(intent);
    } 
 
    private ListAdapter getSampleAdapter() {
        ArrayList<ActivityInfo> items = new ArrayList<ActivityInfo>();
        final String thisClazzName = getClass().getName();
 
        try { 
            PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(),
                    PackageManager.GET_ACTIVITIES);
            ActivityInfo[] aInfos = pInfo.activities;
 
            for (ActivityInfo aInfo : aInfos) {
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: toString, setComponent
         if ( !new SettingsEditor(context).startServiceAtBoot() ) {
            if (DEBUG) Log.d(getClass().getName(), "Yammer configured not to start at boot");
            return; 
         } 
 
         ComponentName comp = new ComponentName(context.getPackageName(), YammerService.class.getName());
         ComponentName service = context.startService(new Intent().setComponent(comp));
 
         if (null == service){
            // something really wrong here 
            Log.e(getClass().getName(), "Could not start service " + comp.toString());
         } 
      } else { 
         Log.e(getClass().getName(), "Received unexpected intent " + intent.toString());
      } 
   } 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Intent setComponent Questions & Answers:

setComponent Method Overview
(Usually optional) Explicitly set the component to handle the intent.
See Code Examples for other Android Intent Methods: