List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.toppatch.mv.ui.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { String TAG = "MainActivity.onCreate"; super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); intent.getExtras(); Boolean bool = intent.getBooleanExtra("fromReciever", false); IntentFilter filter = new IntentFilter(); filter.addAction(EnterpriseLicenseManager.ACTION_LICENSE_STATUS); samsungReciever = new SamsungReceiver(); this.registerReceiver(samsungReciever, filter); if (bool == true) { acceptConditions = (Button) findViewById(R.id.acceptConditionsButton); acceptConditions.setText("Sorry you need to accept conditions to proceed...."); acceptConditions.setClickable(true); } else {/*from ww w.java 2 s .c o m*/ Log.i("see", "oncreate"); checkConditions(); } }
From source file:uk.co.md87.android.sensorlogger.UploaderService.java
@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); headers.clear();/*w w w . j av a 2s . c o m*/ for (String key : intent.getExtras().keySet()) { headers.put(key, intent.getStringExtra(key)); } }
From source file:com.gdglab.iot.gcm.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*/*from ww w . ja va2s.co m*/ * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. // for (int i = 0; i < 5; i++) { // Log.i(TAG, "Working... " + (i + 1) // + "/5 @ " + SystemClock.elapsedRealtime()); // try { // Thread.sleep(5000); // } catch (InterruptedException e) { // } // } // Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. Log.i(TAG, "Received: " + extras.toString()); String text = (String) extras.get("message"); JSONObject json = null; String msgText = ""; try { json = new JSONObject(text); msgText = json.getString("text"); Log.i(TAG, "received text : " + msgText); sendNotification(msgText); } catch (JSONException e) { Log.e(TAG, "Error with JSON message"); e.printStackTrace(); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.liferay.tasks.activity.AddTaskActivity.java
@Override protected void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.activity_add_task); _titleView = (EditText) findViewById(R.id.task); _seekBar = (SeekBar) findViewById(R.id.status_bar); _seekBar.setMax(5);/*from w w w . j a v a 2s.c o m*/ View saveView = findViewById(R.id.save); saveView.setOnClickListener(this); Intent intent = getIntent(); Bundle extras = intent.getExtras(); initialize(extras); }
From source file:com.geekandroid.sdk.sample.JPushReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); Log.d(TAG, "[JPushReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle)); if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) { String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID); Log.d(TAG, "[JPushReceiver] Registration Id : " + regId); //send the Registration Id to your server... } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] ???: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)); processCustomMessage(context, bundle); } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] ??"); int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID); Log.d(TAG, "[JPushReceiver] ??ID: " + notifactionId); } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] "); JPushImpl.getInstance().clearAllNotifications(); //Activity Intent i = new Intent(context, JPushOpenActivity.class); i.putExtras(bundle);/*w ww .ja v a 2 s .c o m*/ //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(i); } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA)); //? JPushInterface.EXTRA_EXTRA ??Activity .. } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) { boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false); Log.w(TAG, "[JPushReceiver]" + intent.getAction() + " connected state change to " + connected); } else { Log.d(TAG, "[JPushReceiver] Unhandled intent - " + intent.getAction()); } }
From source file:com.swisscom.safeconnect.utils.gcm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { setResultCode(Activity.RESULT_OK);//www . ja v a 2 s. co m Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { if (BuildConfig.DEBUG) Log.d(Config.TAG, "Error receiving push notification: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { if (BuildConfig.DEBUG) Log.d(Config.TAG, "Deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (BuildConfig.DEBUG) Log.d(Config.TAG, "Received: " + extras.toString()); String key = extras.getString("key"); String args_json = extras.getString("args"); if (key != null) { int resId = context.getResources().getIdentifier(key, "string", context.getPackageName()); if (resId != 0) { Object[] args = convertJsonToStringArray(args_json); String title = context.getString(R.string.push_title); String msg = context.getString(resId, args); //String title = extras.getString("title"); //String msg = extras.getString("message"); sendNotification(title, msg, context); } } } } }
From source file:com.richtodd.android.quiltdesign.app.OpenRepositoryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_open_repository); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras.containsKey(Intent.EXTRA_STREAM)) { Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); try {//from w w w.j ava 2s.co m JSONObject jsonObject = JSONUtility.loadJSONObject(getContentResolver(), uri); m_repository = new JSONRepository(jsonObject, new QuiltDesignThumbnailProvider()); } catch (RepositoryException e) { Handle.asRuntimeError(e); } } m_text_theme_count = (TextView) findViewById(R.id.text_theme_count); m_text_block_count = (TextView) findViewById(R.id.text_block_count); m_text_quilt_count = (TextView) findViewById(R.id.text_quilt_count); m_radio_import_new = (RadioButton) findViewById(R.id.radio_import_new); m_radio_import_replace = (RadioButton) findViewById(R.id.radio_import_replace); m_radio_import_merge = (RadioButton) findViewById(R.id.radio_import_merge); m_button_import = (Button) findViewById(R.id.button_import); m_button_import.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Repository repository = Repository.getDefaultRepository(OpenRepositoryActivity.this); repository.merge(m_repository, getMergeMode()); Toast.makeText(OpenRepositoryActivity.this, getString(R.string.toast_openRepository_success), Toast.LENGTH_SHORT).show(); finish(); } catch (RepositoryException e) { Handle.asRuntimeError(e); } } }); m_button_cancel_import = (Button) findViewById(R.id.button_cancel_import); m_button_cancel_import.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); if (m_repository != null) { try { m_text_theme_count.setText(Integer.toString(m_repository.getThemes().getCount())); m_text_block_count.setText(Integer.toString(m_repository.getBlocks().getCount())); m_text_quilt_count.setText(Integer.toString(m_repository.getQuilts().getCount())); } catch (RepositoryException e) { Handle.asRuntimeError(e); } } else { m_text_theme_count.setText("0"); m_text_block_count.setText("0"); m_text_quilt_count.setText("0"); } }
From source file:com.cbtec.eliademy.GCMIntentService.java
@Override protected void onMessage(Context context, Intent intent) { Bundle extras = intent.getExtras(); Log.d(TAG, "Received message" + extras.toString()); if (extras != null) { try {// ww w .j a v a 2s. co m JSONObject json; json = new JSONObject().put("event", "notifications"); json.put("notifications", extras.getString("notifications")); Log.v(TAG, json.toString()); if (GCMPlugin.isActive()) { // TODO: Find better way JSONObject msgobj = new JSONObject(extras.getString("notifications")); String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course " + msgobj.getString("coursename"); generateNotification(context, msg); GCMPlugin.sendJavascript(json); } else { // form message JSONObject msgobj = new JSONObject(extras.getString("notifications")); String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course " + msgobj.getString("coursename"); generateNotification(context, msg); } } catch (JSONException e) { Log.e(TAG, "JSON exception" + e.getMessage()); } } }
From source file:de.golov.zeitgeistreich.ZeitGeistReichActivity.java
protected void submitImage(String tags) { Intent intent = getIntent(); Bundle extras = intent.getExtras(); Uri mImageUri = null;/*from w w w . j a v a 2 s. c o m*/ File mFilename = null; if (Intent.ACTION_SEND.equals(intent.getAction()) && extras != null) { if (extras.containsKey(Intent.EXTRA_STREAM)) { mImageUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); if (mImageUri != null) { Cursor cursor = getContentResolver().query(mImageUri, null, null, null, null); if (cursor.moveToFirst()) { mFilename = new File(cursor.getString(cursor.getColumnIndexOrThrow(ImageColumns.DATA))); } cursor.close(); if (mFilename != null) { ZeitGeistReichUploaderTask task = new ZeitGeistReichUploaderTask(); ZeitGeistObject o = new ZeitGeistObject(mFilename, tags); task.execute(o); } } } } }
From source file:com.bakhtiyor.android.tumblr.TumblrService.java
@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Bundle extras = intent.getExtras(); if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null)) { if (extras.containsKey(KEY_EMAIL) && extras.containsKey(KEY_PASSWORD) && extras.containsKey(KEY_CAPTION) && extras.containsKey(KEY_IS_PRIVATE) && extras.containsKey(KEY_FILENAME)) { String email = extras.getString(KEY_EMAIL); String password = extras.getString(KEY_PASSWORD); String caption = extras.getString(KEY_CAPTION); boolean isPrivate = extras.getBoolean(KEY_IS_PRIVATE); String filename = extras.getString(KEY_FILENAME); uploadPhoto(email, password, caption, isPrivate, filename); }//from www .j a v a2 s .c o m } stopSelf(startId); }