Example usage for android.content ComponentName ComponentName

List of usage examples for android.content ComponentName ComponentName

Introduction

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

Prototype

private ComponentName(String pkg, Parcel in) 

Source Link

Usage

From source file:com.claricetechnologies.receivers.ClGcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName component = new ComponentName(context.getPackageName(), ClGcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(component)));
    setResultCode(Activity.RESULT_OK);// w w w  .  jav a2  s  . c  o m
}

From source file:com.amazon.rvspeedtest.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.i("GCMBroadCastReceiver", "Received a message");
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));

    setResultCode(Activity.RESULT_OK);/*from   w  w  w  .j av  a  2 s  .  c  o  m*/
}

From source file:ca.utoronto.ece1778.baton.gcm.client.main.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    Log.i(TAG, context.getPackageName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*from   w  w w  .  ja  v  a2 s . co m*/
}

From source file:com.commonsware.android.rv.transcript.EventDemoActivity.java

@Override
@SuppressLint("MissingPermission")
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, new EventLogFragment())
                .commit();/*from   w  w  w .ja v a  2s  .  c  om*/

        JobScheduler jobs = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
        ComponentName cn = new ComponentName(this, ScheduledService.class);
        JobInfo.Builder b = new JobInfo.Builder(JOB_ID, cn).setRequiredNetworkType(JobInfo.NETWORK_TYPE_NONE)
                .setPeriodic(60000).setPersisted(false).setRequiresCharging(false).setRequiresDeviceIdle(false);

        jobs.schedule(b.build());
    }
}

From source file:com.example.itsatrap.app.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d("IATGcmBroadcastReceiver", "onReceive");
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
            com.example.itsatrap.app.GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*  ww  w.  ja  v  a 2  s .  c om*/
}

From source file:com.example.huanlu.myruns.gcm.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "onReceive()");
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*from  www . j  ava 2  s .co m*/
}

From source file:com.crenativelabs.signchat.gcm.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // Explicitly specify that GcmIntentService will handle the intent.
    //        String className = GcmManager.getInstance(context)
    //                .getHandleIntentServiceCompName();
    ComponentName comp = new ComponentName(context.getPackageName(), MyGcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*  ww w.  j  av  a 2 s. co  m*/
}

From source file:com.diusrex.toforeground.ToForeground.java

public boolean execute(String className, JSONArray args, CallbackContext callbackContext) throws JSONException {
    try {//from  ww w  . j av  a 2 s  .com
        Intent it = new Intent("android.intent.action.MAIN");

        String packageName = args.getString(0);

        Activity activity = this.cordova.getActivity();
        it.setComponent(new ComponentName(packageName, packageName + "." + className));
        it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        Context context = activity.getApplicationContext();
        context.startActivity(it);
    } catch (Exception e) {
        return false;
    }
    return true;
}

From source file:com.burhan.udacity.popularmovies.ui.activity.PreferenceActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = getToolbar();/*from   w w  w .  j  a v  a2s . co  m*/
    if (toolbar != null) {
        toolbar.setTitle(R.string.title_settings);
        toolbar.setNavigationIcon(R.drawable.ic_up);
        toolbar.setNavigationOnClickListener(view -> navigateUpToFromChild(PreferenceActivity.this, IntentCompat
                .makeMainActivity(new ComponentName(PreferenceActivity.this, BrowseMoviesActivity.class))));
    }

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction().add(R.id.container, new SettingsFragment()).commit();
    }
}

From source file:com.example.android.sampletvinput.syncservice.SyncUtils.java

public static void requestSync(Context context, String inputId, boolean currentProgramOnly) {
    PersistableBundle pBundle = new PersistableBundle();
    pBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
    pBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
    pBundle.putString(SyncJobService.BUNDLE_KEY_INPUT_ID, inputId);
    pBundle.putBoolean(SyncJobService.BUNDLE_KEY_CURRENT_PROGRAM_ONLY, currentProgramOnly);
    JobInfo.Builder builder = new JobInfo.Builder(REQUEST_SYNC_JOB_ID,
            new ComponentName(context, SyncJobService.class));
    JobInfo jobInfo = builder.setExtras(pBundle).setOverrideDeadline(SyncJobService.OVERRIDE_DEADLINE_MILLIS)
            .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).build();
    scheduleJob(context, jobInfo);//from   w ww  .j a  v a 2 s.  c  om
    Intent intent = new Intent(SyncJobService.ACTION_SYNC_STATUS_CHANGED);
    intent.putExtra(SyncJobService.BUNDLE_KEY_INPUT_ID, inputId);
    intent.putExtra(SyncJobService.SYNC_STATUS, SyncJobService.SYNC_STARTED);
    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}