List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:edu.umich.flowfence.common.QMDescriptor.java
public static QMDescriptor forConstructor(Context context, Class<?> definingClass, Class<?>... paramTypes) { if (!ParceledPayload.canParcelType(definingClass)) { throw new ParcelFormatException("Can't parcel constructed type"); }/* w w w .j a va2s . c om*/ return new QMDescriptor(KIND_CTOR, new ComponentName(context, definingClass), null, toNames(paramTypes), false); }
From source file:com.android.server.telecom.testapps.CallNotificationReceiver.java
public static void addNewUnknownCall(Context context, Uri handle, Bundle extras) { Log.i(TAG, "Adding new unknown call with handle " + handle); PhoneAccountHandle phoneAccount = new PhoneAccountHandle( new ComponentName(context, TestConnectionService.class), CallServiceNotifier.SIM_SUBSCRIPTION_ID); if (extras == null) { extras = new Bundle(); }//from w w w . ja va 2 s. c o m if (handle != null) { extras.putParcelable(TelecomManager.EXTRA_UNKNOWN_CALL_HANDLE, handle); extras.putParcelable(TestConnectionService.EXTRA_HANDLE, handle); } TelecomManager.from(context).addNewUnknownCall(phoneAccount, extras); }
From source file:com.chale22.ico01.fragments.FragmentExtras.java
private void actWallpapers() { String pkg = getResources().getString(R.string.pkg); Intent wallpapers = new Intent(Intent.ACTION_MAIN); wallpapers.setComponent(new ComponentName(pkg, pkg + ".wallpaper")); try {/*from ww w .jav a 2s . co m*/ startActivity(wallpapers); } catch (RuntimeException wall) { wall.printStackTrace(); } }
From source file:edu.umich.oasis.common.SodaDescriptor.java
public static SodaDescriptor forConstructor(Context context, Class<?> definingClass, Class<?>... paramTypes) { if (!ParceledPayload.canParcelType(definingClass)) { throw new ParcelFormatException("Can't parcel constructed type"); }/*from w w w .ja va 2 s . c o m*/ return new SodaDescriptor(KIND_CTOR, new ComponentName(context, definingClass), null, toNames(paramTypes), false); }
From source file:com.afwsamples.testdpc.provision.PostProvisioningTask.java
public boolean performPostProvisioningOperations(Intent intent) { if (isPostProvisioningDone()) { return false; }/*from w w w . ja v a 2 s . co m*/ markPostProvisioningDone(); // From M onwards, permissions are not auto-granted, so we need to manually grant // permissions for TestDPC. if (Util.isAtLeastM()) { autoGrantRequestedPermissionsToSelf(); } // Retreive the admin extras bundle, which we can use to determine the original context for // TestDPCs launch. PersistableBundle extras = intent.getParcelableExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE); if (BuildCompat.isAtLeastO()) { maybeSetAffiliationIds(extras); } // Hide the setup launcher when this app is the admin mContext.getPackageManager().setComponentEnabledSetting( new ComponentName(mContext, SETUP_MANAGEMENT_LAUNCH_ACTIVITY), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); return true; }
From source file:com.commonsware.android.sawmonitor.SAWDetector.java
@TargetApi(Build.VERSION_CODES.O) static void scheduleJobs(Context ctxt) { SAWDetector.seeSAW(ctxt);//from w w w . ja va 2 s .c om ComponentName cn = new ComponentName(ctxt, PollingService.class); JobInfo.Builder b = new JobInfo.Builder(JOB_ID, cn).setRequiredNetworkType(JobInfo.NETWORK_TYPE_NONE) .setPeriodic(15 * 60 * 1000, 60000).setPersisted(true).setRequiresCharging(false) .setRequiresDeviceIdle(false); ctxt.getSystemService(JobScheduler.class).schedule(b.build()); }
From source file:com.android.settings.aokpstats.ReportingService.java
private void promptUser() { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent nI = new Intent(); nI.setComponent(new ComponentName(getPackageName(), Settings.AnonymousStatsActivity.class.getName())); PendingIntent pI = PendingIntent.getActivity(this, 0, nI, 0); Notification.Builder builder = new Notification.Builder(this).setSmallIcon(R.drawable.ic_aokp_stats_notif) .setAutoCancel(true).setTicker(getString(R.string.anonymous_statistics_title)).setContentIntent(pI) .setWhen(0).setContentTitle(getString(R.string.anonymous_statistics_title)) .setContentText(getString(R.string.anonymous_notification_desc)); nm.notify(1, builder.getNotification()); }
From source file:com.adwhirl.AdWhirlLayout.java
protected String getAdWhirlKey(Context context) { final String packageName = context.getPackageName(); final String activityName = context.getClass().getName(); final PackageManager pm = context.getPackageManager(); Bundle bundle = null;/*from w w w . j a v a2 s . c o m*/ // Attempts to retrieve Activity-specific AdWhirl key first. If not // found, retrieve Application-wide AdWhirl key. try { ActivityInfo activityInfo = pm.getActivityInfo(new ComponentName(packageName, activityName), PackageManager.GET_META_DATA); bundle = activityInfo.metaData; if (bundle != null) { return bundle.getString(AdWhirlLayout.ADWHIRL_KEY); } } catch (NameNotFoundException exception) { // Activity cannot be found. Shouldn't be here. return null; } try { ApplicationInfo appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); bundle = appInfo.metaData; if (bundle != null) { return bundle.getString(AdWhirlLayout.ADWHIRL_KEY); } } catch (NameNotFoundException exception) { // Application cannot be found. Shouldn't be here. return null; } return null; }
From source file:android.support.v7.media.MediaRouteProvider.java
MediaRouteProvider(Context context, ProviderMetadata metadata) { if (context == null) { throw new IllegalArgumentException("context must not be null"); }/*from w ww . ja va 2 s .c o m*/ mContext = context; if (metadata == null) { mMetadata = new ProviderMetadata(new ComponentName(context, getClass())); } else { mMetadata = metadata; } }
From source file:edu.umich.oasis.testapp.TestActivity.java
public void runTest(View ignored) { try {//from w w w. j a v a 2 s . c om setButtonsEnabled(false); OASISConnection conn = connection; // start resolving init0 = conn.resolveConstructor(TestSoda.class); init1 = conn.resolveConstructor(TestSoda.class, String.class); concat = conn.resolveStatic(String.class, TestSoda.class, "concat", String.class, String.class); getState = conn.resolveInstance(String.class, TestSoda.class, "getState"); swapState = conn.resolveInstance(String.class, TestSoda.class, "swapState", String.class); log = conn.resolveInstance(void.class, TestSoda.class, "log", String.class); logStatic = conn.resolveStatic(void.class, TestSoda.class, "log", String.class, String.class); throwStatic = conn.resolveStatic(String.class, TestSoda.class, "throwStatic", String.class); throwInstance = conn.resolveInstance(void.class, TestSoda.class, "throwInstance", String.class); sleep = conn.resolveStatic(String.class, TestSoda.class, "sleep", long.class); Log.i(TAG, "Done resolving"); ComponentName cn = new ComponentName(getPackageName(), "testChannel"); SodaDescriptor sd = logStatic.getDescriptor(); conn.getRawInterface().subscribeEventChannel(cn, sd); Log.i(TAG, "Constructing with init0"); Sealed<TestSoda> obj1 = init0.call(); obj1.buildCall(log).arg("obj1").call(); Log.i(TAG, "Constructing with init1"); Sealed<TestSoda> obj2 = init1.arg("<foobar>").call(); Sealed<String> obj2State = getState.arg(obj2).call(); logStatic.arg("obj2State").arg(obj2State).call(); Log.i(TAG, "Calling static method"); Sealed<String> newState = concat.arg("state").arg(obj2State).call(); logStatic.arg("newState").arg(newState).call(); Log.i(TAG, "Calling instance with inout"); Sealed<String> oldState1 = swapState.inOut(obj1).arg(newState).call(); logStatic.arg("oldState1").arg(oldState1).call(); obj1.buildCall(log).arg("obj1'").call(); Log.i(TAG, "Calling instance without inout"); Sealed<String> oldState2 = swapState.in(obj2).arg(newState).call(); logStatic.arg("oldState2").arg(oldState2).call(); obj2.buildCall(log).arg("obj2'").call(); Log.i(TAG, "Testing exception propagation - static"); Sealed<String> excStatic = throwStatic.in("static test #1").call(); Sealed<String> excStatic2 = throwStatic.in("static test #2").call(); logStatic.arg(excStatic).arg(excStatic2).call(); Log.i(TAG, "Testing exception propagation - instance"); obj1.buildCall(throwInstance).arg("instance test - obj1").call(); obj1.buildCall(log).argNull().call(); throwInstance.in(obj2).arg("instance test - obj2").call(); obj2.buildCall(log).argNull().call(); Log.i(TAG, "Testing async method calls"); Sealed<String> sleepResult = sleep.arg(15 * 1000L).asAsync().call(); logStatic.arg("Sleep result").arg(sleepResult).asAsync().call(); Log.i(TAG, "All done!"); } catch (Exception e) { Log.wtf(TAG, "Exception in post-connect handler", e); } finally { Log.i(TAG, "Finishing"); setButtonsEnabled(true); } }