List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:com.example.AllSOS.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), Activity.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/* w ww . j a va 2s . c o m*/ String message = intent.getStringExtra("message"); Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG); toast.show(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("O meu Pedido").setContentText(message); Intent resultIntent = new Intent(context, SelectServiceActivity.class); // Because clicking the notification opens a new ("special") activity, there's // no need to create an artificial back stack. PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); int mNotificationId = 001; // Gets an instance of the NotificationManager service NotificationManager mNotifyMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // Builds the notification and issues it. mNotifyMgr.notify(mNotificationId, mBuilder.build()); }
From source file:com.beintoo.beclubapp.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), com.beintoo.beclubapp.GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);// w ww . j av a 2 s . c o m }
From source file:com.appdynamics.demo.gasp.gcm.GCMBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Received GCM 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);// w w w. j av a 2s. com }
From source file:com.binarywalllabs.sendit.managers.gcm.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()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/*from ww w. ja va2 s.c om*/ }
From source file:com.example.android.powerreceiver.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button broadcastButton = (Button) findViewById(R.id.broadcastButton); //Get the PackageManager and ComponentName so you can toggle to broadcast receiver. mReceiverComponentName = new ComponentName(this, CustomReceiver.class); mPackageManager = getPackageManager(); //Use LocalBroadcastManager so that the broadcast is not received by other applications. LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, new IntentFilter(CustomReceiver.ACTION_CUSTOM_BROADCAST)); //onClick method for the button broadcastButton.setOnClickListener(new View.OnClickListener() { @Override//from w w w .j ava2s.c o m public void onClick(View view) { sendCustomBroadcast(); } }); }
From source file:me.sandrin.xkcdwidget.XKCDAppWidgetProvider.java
private void update(Context context) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.app_widget_layout); ComponentName watchWidget = new ComponentName(context, XKCDAppWidgetProvider.class); title = context.getResources().getString(R.string.error_title); image = null;// w w w. j ava 2 s .co m altText = context.getResources().getString(R.string.error_text); updateComicInfo(); updateRemoteViews(context, remoteViews); appWidgetManager.updateAppWidget(watchWidget, remoteViews); }
From source file:ca.zadrox.dota2esportticker.ui.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = getActionBarToolbar(); toolbar.setTitle("Settings"); toolbar.setNavigationIcon(R.drawable.ic_up); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override//from ww w. ja v a 2 s .co m public void onClick(View v) { navigateUpToFromChild(SettingsActivity.this, IntentCompat .makeMainActivity(new ComponentName(SettingsActivity.this, MatchActivity.class))); } }); if (savedInstanceState == null) { getFragmentManager().beginTransaction().add(R.id.container, new SettingsFragment()).commit(); } }
From source file:com.example.AllSOSservice.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), Activity.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);//from w ww . j ava2s. co m String message = intent.getStringExtra("message"); String email = intent.getStringExtra("email"); String latitude = intent.getStringExtra("latitude"); String longitude = intent.getStringExtra("longitude"); Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG); toast.show(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("Novo Pedido de Ajuda!") .setContentText("Alguem precisa de um " + message); Intent resultIntent = null; try { if (isLoggedIn()) { resultIntent = new Intent(context, LoggedInActivity.class); } else { resultIntent = new Intent(context, LoginActivity.class); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } catch (TimeoutException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } // Because clicking the notification opens a new ("special") activity, there's // no need to create an artificial back stack. PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); int mNotificationId = 001; // Gets an instance of the NotificationManager service NotificationManager mNotifyMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // Builds the notification and issues it. mNotifyMgr.notify(mNotificationId, mBuilder.build()); }
From source file:com.ratusapparatus.tapsaff.TapsAff.java
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { super.onUpdate(context, appWidgetManager, appWidgetIds); ComponentName thisWidget = new ComponentName(context, TapsAff.class); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); views.setTextViewText(R.id.main, "ehh..."); appWidgetManager.updateAppWidget(thisWidget, views); RetreiveFeedTask task = new RetreiveFeedTask(); task.context = context;/* w w w .ja va2s . co m*/ task.appWidgetManager = appWidgetManager; task.execute("http://www.taps-aff.co.uk/taps.json"); }
From source file:com.bayapps.android.robophish.ui.tv.TvPlaybackActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LogHelper.d(TAG, "Activity onCreate"); mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MusicService.class), mConnectionCallback, null);//from ww w. j a va 2 s .c o m setContentView(R.layout.tv_playback_controls); mPlaybackFragment = (TvPlaybackFragment) getSupportFragmentManager() .findFragmentById(R.id.playback_controls_fragment); }