List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:edu.umich.oasis.common.SodaDescriptor.java
public static SodaDescriptor forInstance(Context context, Class<?> definingClass, String methodName, Class<?>... paramTypes) { if (!ParceledPayload.canParcelType(definingClass)) { throw new ParcelFormatException("Can't parcel instance type"); }/* ww w. jav a 2 s . c o m*/ return new SodaDescriptor(KIND_INSTANCE, new ComponentName(context, definingClass), methodName, toNames(paramTypes), false); }
From source file:com.miuidev.themebrowser.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.MenuThemeManager: final Intent intentThemeManager = new Intent("android.intent.action.MAIN"); intentThemeManager.setComponent(new ComponentName("com.android.thememanager", "com.android.thememanager.ThemeSettingsActivity")); try {/*from w ww.j a v a 2 s . co m*/ startActivity(intentThemeManager); } catch (ActivityNotFoundException e) { Context context = getApplicationContext(); CharSequence text = getString(R.string.theme_manager_not_found); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } return true; case R.id.MenuAbout: displayAbout(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:am.roadpolice.roadpolice.alarm.AlarmReceiver.java
/** * This function creates a new Alarm by given alarm type. if not {@link AlarmType#NONE} * value was given as a type alarm will be called Daily, Weekly or Monthly staring from * time when this function was called. All alarms which were created before will be canceled. * * @param context Application context//ww w . j ava 2 s . c o m * @param type Alarm Type, accepted values are * {@link AlarmType#NONE} if need to cancel all alarms, * {@link AlarmType#DAILY} alarm will called daily * {@link AlarmType#WEEKLY} alarm will called weekly * {@link AlarmType#MONTHLY} alarm will called monthly */ public static void createAlarm(final Context context, AlarmType type) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); switch (type) { case DAILY: calendar.add(Calendar.DATE, 1); break; case WEEKLY: calendar.add(Calendar.DATE, 7); break; case MONTHLY: calendar.add(Calendar.MONTH, 1); break; } // Create Alarm Manager Object. if (mAlarmManager == null) mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // Intent intent = new Intent(context, AlarmReceiver.class); if (mAlarmIntent == null) mAlarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); // Remove all previously created alarms, before creating new one. if (mAlarmManager != null) { mAlarmManager.cancel(mAlarmIntent); // By default Disable Boot Receiver. int componentEnabledState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; // For enabling/disabling Boot Receiver. ComponentName receiver = new ComponentName(context, AlarmReceiver.class); PackageManager pm = context.getPackageManager(); // Set new alarm if provided interval is not none. if (!AlarmType.NONE.equals(type)) { Logger.debug("AlarmReceiver", String .format("----> Next Update Date: %1$tA %1$tb %1$td %1$tY at %1$tI:%1$tM %1$Tp", calendar)); // Enables Boot Receiver. componentEnabledState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; // Set repeating alarm. final long timeInMillis = calendar.getTimeInMillis(); mAlarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, timeInMillis, type.getValue(), mAlarmIntent); // Stores next Alert Time. PreferenceUtils.storeDataLong(context, PreferenceUtils.KEY_ALERT_TIME_IN_MILLIS, timeInMillis); } else { PreferenceUtils.storeDataLong(context, PreferenceUtils.KEY_ALERT_TIME_IN_MILLIS, -1); } pm.setComponentEnabledSetting(receiver, componentEnabledState, PackageManager.DONT_KILL_APP); } }
From source file:cn.laojing.smarthome.VoiceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.voice);//from w w w .j a v a 2 s. co m setListAdapter(mListViewAdapter); speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new ComponentName(this, VoiceRecognitionService.class)); speechRecognizer.setRecognitionListener(this); initialEnv(); initialTts(); mSpeechSynthesizer.speak("?"); mVoiceControl = new VoiceControl(this, mSpeechSynthesizer); imgBtn = (ImageView) findViewById(R.id.imageView); imgBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { start(); } }); Intent bindIntent = new Intent(this, CommandService.class); bindService(bindIntent, connection, BIND_AUTO_CREATE); //start(); }
From source file:com.ratusapparatus.tapsaff.TapsAff.java
protected void onPostExecute(String feed) { ComponentName thisWidget = new ComponentName(context, TapsAff.class); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); Log.i("tapsaffonPostExecuteFeed", feed); JSONObject jsonObj;/* w w w . j a v a2 s . co m*/ try { jsonObj = new JSONObject(feed); /*for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); Log.i(TapsAff.class.getName(), jsonObject.getString("text")); }*/ String oanAff = jsonObj.get("taps").toString(); Integer itsClose = (Integer) jsonObj.get("temp_f"); if (itsClose >= TapsAff.tapsTemp - 5 && itsClose <= TapsAff.tapsTemp) views.setViewVisibility(R.id.bottom, View.VISIBLE); else views.setViewVisibility(R.id.bottom, View.GONE); String colour = "blue"; if (oanAff == "Aff") colour = "red"; String text = "taps" + " " + "<font color='" + colour + "'>" + oanAff + "</font>"; //textView.setText(, TextView.BufferType.SPANNABLE); views.setTextViewText(R.id.main, Html.fromHtml(text)); } catch (Exception e) { Log.i("tapsaffonPostExecuteException", e.getLocalizedMessage()); } appWidgetManager.updateAppWidget(thisWidget, views); }
From source file:edu.umich.flowfence.common.QMDescriptor.java
public static QMDescriptor forStatic(Context context, Class<?> definingClass, String methodName, Class<?>... paramTypes) { return new QMDescriptor(KIND_STATIC, new ComponentName(context, definingClass), methodName, toNames(paramTypes), false); }
From source file:com.mono.applink.Facebook.java
/** Called when the activity is first created. */ @Override/*from w ww.ja v a2s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; final String url = getIntent().getData().toString(); if (url.contains("posts") || url.contains("profile.php") || (!url.contains("&") && !url.contains("=") && url.length() > 24)) //1)Posts->It is impossible to launch FeedbackActivity because of permission denied. //With root permission and "am start" it's impossible to pass a Long extra_key... //2)Profile //3)Nickname { new FacebookUser().execute(); } else if (url.contains("sk=inbox"))//Message { new FacebookMessage().execute(); } else if (url.contains("event.php"))//event { new FacebookEvent().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:edu.umich.oasis.common.SodaDescriptor.java
public static SodaDescriptor forStatic(Context context, Class<?> definingClass, String methodName, Class<?>... paramTypes) { return new SodaDescriptor(KIND_STATIC, new ComponentName(context, definingClass), methodName, toNames(paramTypes), false); }
From source file:com.b44t.messenger.MusicPlayerService.java
@SuppressLint("NewApi") @Override//w ww . j a va 2 s .c om public int onStartCommand(Intent intent, int flags, int startId) { try { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { FileLog.e("messenger", e); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:com.battlelancer.seriesguide.extensions.ExtensionManager.java
private ExtensionManager(Context context) { Timber.d("Initializing extension manager"); mContext = context.getApplicationContext(); mSharedPrefs = mContext.getSharedPreferences(PREF_FILE_SUBSCRIPTIONS, 0); mSubscriberComponentName = new ComponentName(mContext, ExtensionSubscriberService.class); loadSubscriptions();//from w ww. j a va 2s. com }