List of utility methods to do Context Set
void | scanMediaFiles(final Context context, String[] files, String[] mimeTypes) scan Media Files MediaScannerConnection.scanFile(context, files, mimeTypes, new OnScanCompletedListener() { @Override public void onScanCompleted(String arg0, Uri arg1) { }); |
void | sendKey(Context c, int action, int keycode) Create and send a KeyEvent through the AudioService, failback to a simple intent broadcast if necessary.On KitKat, the event should be send by the service, otherwise it's not working with SELinux enforced mode. long eventtime = SystemClock.uptimeMillis(); KeyEvent keyEvent = new KeyEvent(eventtime, eventtime, action, keycode, 0); if (!sendMediaKeyEventViaAudioService(keyEvent)) { Intent downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent); c.sendOrderedBroadcast(downIntent, null); |
void | sendKey(Context c, int keyCode) Send two KeyEvent, one with Action_down and then one with Action_up sendKey(c, KeyEvent.ACTION_DOWN, keyCode); sendKey(c, KeyEvent.ACTION_UP, keyCode); |
void | sendPlayPauseKey(Context c) send Play Pause Key sendKey(c, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE); |
boolean | sendSms(@Nonnull Context context, @CheckForNull String number, @Nullable String text) Sends an SMS message to the given number with the passed text. boolean success = true; if (hasTelephony(context)) { if (number == null || !PhoneNumberUtils.isWellFormedSmsAddress(number)) { number = ""; success = false; Intent smsIntent = new Intent(Intent.ACTION_SENDTO, ... |
void | sendStopKey(Context c) send Stop Key sendKey(c, KeyEvent.KEYCODE_MEDIA_STOP); |
void | setAppContext(Context context) set App Context sContext = context; |
void | setBaiduServiceEnabled(Context paramContext, boolean paramBoolean) set Baidu Service Enabled if (paramBoolean) ; for (int i = 1;; i = 2) { paramContext.getPackageManager().setComponentEnabledSetting( new ComponentName(paramContext.getPackageName(), "com.baidu.location.f"), i, 1); return; |
void | setContext(Application app) set Context context = app.getApplicationContext(); |
void | setDefaultLocale(Context context, String locale) Change the default locale of the application for this activity Locale locJa = new Locale(locale); Locale.setDefault(locJa); Configuration config = new Configuration(); config.locale = locJa; if (context != null) { context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); |