List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.snappy.GCMIntentService.java
/** * Method called on Receiving a new message * *///w w w . j a v a 2s. c o m @Override protected void onMessage(Context context, Intent intent) { db = new LocalDB(context); Bundle pushExtras = intent.getExtras(); String pushMessage = intent.getStringExtra(Const.PUSH_MESSAGE); String pushFromName = intent.getStringExtra(Const.PUSH_FROM_NAME); String pushMessageBody = intent.getStringExtra(Const.PUSH_FROM_MESSAGE_BODY); String pushMessaBodyStyled = pushFromName + ": " + pushMessageBody; db.writeMessage(pushMessaBodyStyled); try { boolean appIsInForeground = new SpikaApp.ForegroundCheckAsync().execute(getApplicationContext()).get(); boolean screenLocked = ((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode(); if (appIsInForeground && !screenLocked) { mPushBroadcast.replaceExtras(pushExtras); LocalBroadcastManager.getInstance(this).sendBroadcast(mPushBroadcast); generateNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); } else { //triggerNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); generateNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } }
From source file:cc.softwarefactory.lokki.android.services.LocationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e(TAG, "onStartCommand invoked"); if (intent == null) { return START_STICKY; }//w ww .j a v a 2s . com Bundle extras = intent.getExtras(); if (extras == null) { return START_STICKY; } if (extras.containsKey(RUN_1_MIN)) { Log.e(TAG, "onStartCommand RUN_1_MIN"); setTemporalTimer(); } else if (extras.containsKey(ALARM_TIMER)) { Log.e(TAG, "onStartCommand ALARM_TIMER"); stopSelf(); } return START_STICKY; }
From source file:com.liferay.mobile.push.util.GoogleServices.java
public JSONObject getPushNotification(Context context, Intent intent) throws PushNotificationReceiverException { String messageType = getMessageType(context, intent); if (!GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { throw new PushNotificationReceiverException("Unknown message type" + messageType); }//from w w w. j a v a 2 s. c om Bundle extras = intent.getExtras(); if ((extras == null) || extras.isEmpty()) { throw new PushNotificationReceiverException("Push notification body is empty."); } String payload = extras.getString("payload", null); if (payload == null) { throw new PushNotificationReceiverException("Push notification without payload."); } try { JSONObject pushNotification = new JSONObject(payload); return pushNotification; } catch (JSONException je) { throw new PushNotificationReceiverException(je); } }
From source file:org.zywx.wbpalmstar.platform.push.PushRecieveMsgReceiver.java
private void newPushNotification(Context context, Intent intent) { PushReportUtility.log("newPushNotification->isForground = " + EBrowserActivity.isForground); Bundle bundle = intent.getExtras(); PushDataInfo dataInfo = (PushDataInfo) bundle.get(PushReportConstants.PUSH_DATA_INFO_KEY); int contentAvailable = dataInfo.getContentAvailable(); if (contentAvailable == 0 && !EBrowserActivity.isForground) { buildPushNotification(context, intent, dataInfo); } else {/* ww w . j a v a 2s.c o m*/ if (mContext != null) { intent.putExtra("ntype", F_TYPE_PUSH); intent.putExtra("data", dataInfo.getAlert()); intent.putExtra("message", dataInfo.getPushDataString()); ((EBrowserActivity) mContext).handleIntent(intent); } } }
From source file:cc.softwarefactory.lokki.android.services.DataService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e(TAG, "onStartCommand invoked"); if (intent == null) { return START_STICKY; }/*from ww w . j a va 2 s . co m*/ // Check that intent isnt null, and service is connected to Google Play Services Bundle extras = intent.getExtras(); if (extras == null) { return START_STICKY; } if (extras.containsKey(ALARM_TIMER)) { fetchDashboard(); } else if (extras.containsKey(GET_PLACES)) { getPlaces(); } return START_STICKY; }
From source file:com.example.parking.ParkingInformationActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDBAdapter = new DBAdapter(this); setContentView(R.layout.activity_parking_information); mParkNameTV = (TextView) findViewById(R.id.tv_parking_name); mParkNameTV.setText(R.string.park_name_fixed); mParkNumberTV = (TextView) findViewById(R.id.tv_parking_number); mParkNumberTV.setText("?:" + this.getString(R.string.park_number_fixed)); mCarType = (Spinner) findViewById(R.id.sp_car_type); mParkingType = (Spinner) findViewById(R.id.sp_parking_type); mLocationNumber = (Spinner) findViewById(R.id.sp_parking_location); mLicensePlateNumberTV = (TextView) findViewById(R.id.tv_license_plate_number); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); mLicensePlateNumberTV.setText(bundle.getString("licensePlate")); mStartTime = (TextView) findViewById(R.id.tv_start_time_arriving); new TimeThread().start(); mOkButton = (Button) findViewById(R.id.bt_confirm_arriving); mOkButton.setOnClickListener(new InsertOnclickListener(mLicensePlateNumberTV.getText().toString(), mCarType.getSelectedItem().toString(), mParkingType.getSelectedItem().toString(), Integer.parseInt(mLocationNumber.getSelectedItem().toString()), DateFormat.format("yyyy-MM-dd HH:mm:ss", System.currentTimeMillis()).toString(), null, null, "")); mPhotoBT = (Button) findViewById(R.id.bt_camera_arriving); mPhotoBT.setOnClickListener(new Button.OnClickListener() { @Override/*from w ww . j a v a 2 s . c om*/ public void onClick(View v) { if (mEnterImage != null) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT) .show(); } else { openTakePhoto(); } } }); mPhotoTitleTV = (TextView) findViewById(R.id.tv_photo_title_arriving); mEnterImageIV = (ImageView) findViewById(R.id.iv_photo_arriving); mEnterImageIV.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null); // final AlertDialog dialog = new AlertDialog.Builder(ParkingInformationActivity.this).create(); ImageView img = (ImageView) imgEntryView.findViewById(R.id.iv_large_image); Button deleteBT = (Button) imgEntryView.findViewById(R.id.bt_delete_image); img.setImageBitmap(mEnterImage); dialog.setView(imgEntryView); // dialog dialog.show(); imgEntryView.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { dialog.cancel(); } }); deleteBT.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { mEnterImage = null; mEnterImageIV.setImageResource(drawable.ic_photo_background_64px); dialog.cancel(); } }); } }); getActionBar().setDisplayHomeAsUpEnabled(true); IntentFilter filter = new IntentFilter(); filter.addAction("ExitApp"); registerReceiver(mReceiver, filter); }
From source file:my.home.lehome.service.SendMsgIntentService.java
private void preparePengindCommand(Intent intent) { Messenger messenger;/*from w ww . jav a 2 s . co m*/ if (intent.hasExtra("messenger")) messenger = (Messenger) intent.getExtras().get("messenger"); else messenger = null; Message repMsg = Message.obtain(); repMsg.what = MSG_BEGIN_SENDING; boolean isSysCmd = intent.getBooleanExtra("isSysCmd", false); if (isSysCmd) { Log.d(TAG, "sys cmd item"); return; } ChatItem item = intent.getParcelableExtra("update"); if (item == null) { item = new ChatItem(); item.setContent(intent.getStringExtra("cmd")); item.setType(ChatItemConstants.TYPE_CLIENT); item.setState(Constants.CHATITEM_STATE_ERROR); // set ERROR item.setDate(new Date()); DBStaticManager.addChatItem(getApplicationContext(), item); } item.setState(Constants.CHATITEM_STATE_PENDING); Log.d(TAG, "enqueue item: \n" + item); Bundle bundle = new Bundle(); bundle.putBoolean("update", intent.hasExtra("update")); bundle.putParcelable("item", item); if (messenger != null) { repMsg.setData(bundle); try { messenger.send(repMsg); } catch (RemoteException e) { e.printStackTrace(); } } else { Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_BEGIN); Intent newIntent = new Intent(ACTION_SEND_MSG_BEGIN); newIntent.putExtras(bundle); sendBroadcast(newIntent); } intent.putExtra("pass_item", item); }
From source file:fr.cph.stock.android.activity.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); switch (resultCode) { case 100:/*from w w w . j av a 2 s . com*/ finish(); break; case Activity.RESULT_OK: Bundle b = data.getExtras(); portfolio = b.getParcelable("portfolio"); ada.update(portfolio); break; } }
From source file:edu.umich.flowfence.sandbox.SandboxService.java
@Override public IBinder onBind(Intent i) { if (localLOGD) { Log.d(TAG, "Bound"); }//from w ww. j a v a2 s . c o m Bundle extras = i.getExtras(); if (extras == null) { throw new IllegalArgumentException("No extras"); } IBinder api = extras.getBinder(EXTRA_TRUSTED_API); if (api == null) { throw new IllegalArgumentException("Trusted API not found in extras"); } IBinder root = extras.getBinder(EXTRA_ROOT_SERVICE); if (root == null) { throw new IllegalArgumentException("FlowfenceService not found in extras"); } mTrustedAPI = ITrustedAPI.Stub.asInterface(api); mRootService = IFlowfenceService.Stub.asInterface(root); mID = extras.getInt(EXTRA_SANDBOX_ID, -1); if (localLOGV) { ClassLoader cl = getClassLoader(); Log.v(TAG, "ClassLoader chain:"); while (cl != null) { Log.v(TAG, cl.toString()); cl = cl.getParent(); } Log.v(TAG, "<end of chain>"); } final String[] packagesToLoad = extras.getStringArray(EXTRA_KNOWN_PACKAGES); getBackgroundHandler().post(new Runnable() { @Override public void run() { if (localLOGD) { Log.d(TAG, "Preloading resolve code"); } // Run through a fake transaction, to preload the appropriate classes. QMDescriptor preloadDesc = QMDescriptor.forStatic(SandboxService.this, SandboxService.class, "resolveStub"); Binder testBinder = new Binder() { @Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { return mBinder.onTransact(code, data, reply, flags); } }; testBinder.attachInterface(null, ""); ISandboxService proxy = ISandboxService.Stub.asInterface(testBinder); try { proxy.resolveQM(preloadDesc, false, null); } catch (Exception e) { Log.w(TAG, "Couldn't preload resolve", e); } if (localLOGD) { Log.d(TAG, "Preloading packages"); } // Load up packages the trusted service tells us we might need. for (String packageName : ArrayUtils.nullToEmpty(packagesToLoad)) { try { if (localLOGD) { Log.d(TAG, "Preloading " + packageName); } getContextForPackage(packageName); } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Can't preload package", e); } } Log.i(TAG, "Sandbox #" + mID + ": preload complete"); } }); return mBinder; }
From source file:edu.umich.oasis.sandbox.SandboxService.java
@Override public IBinder onBind(Intent i) { if (localLOGD) { Log.d(TAG, "Bound"); }/*from w w w .ja v a 2 s . c o m*/ Bundle extras = i.getExtras(); if (extras == null) { throw new IllegalArgumentException("No extras"); } IBinder api = extras.getBinder(EXTRA_TRUSTED_API); if (api == null) { throw new IllegalArgumentException("Trusted API not found in extras"); } IBinder root = extras.getBinder(EXTRA_ROOT_SERVICE); if (root == null) { throw new IllegalArgumentException("OASISService not found in extras"); } mTrustedAPI = ITrustedAPI.Stub.asInterface(api); mRootService = IOASISService.Stub.asInterface(root); mID = extras.getInt(EXTRA_SANDBOX_ID, -1); if (localLOGV) { ClassLoader cl = getClassLoader(); Log.v(TAG, "ClassLoader chain:"); while (cl != null) { Log.v(TAG, cl.toString()); cl = cl.getParent(); } Log.v(TAG, "<end of chain>"); } final String[] packagesToLoad = extras.getStringArray(EXTRA_KNOWN_PACKAGES); getBackgroundHandler().post(new Runnable() { @Override public void run() { if (localLOGD) { Log.d(TAG, "Preloading resolve code"); } // Run through a fake transaction, to preload the appropriate classes. SodaDescriptor preloadDesc = SodaDescriptor.forStatic(SandboxService.this, SandboxService.class, "resolveStub"); Binder testBinder = new Binder() { @Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { return mBinder.onTransact(code, data, reply, flags); } }; testBinder.attachInterface(null, ""); ISandboxService proxy = ISandboxService.Stub.asInterface(testBinder); try { proxy.resolveSoda(preloadDesc, false, null); } catch (Exception e) { Log.w(TAG, "Couldn't preload resolve", e); } if (localLOGD) { Log.d(TAG, "Preloading packages"); } // Load up packages the trusted service tells us we might need. for (String packageName : ArrayUtils.nullToEmpty(packagesToLoad)) { try { if (localLOGD) { Log.d(TAG, "Preloading " + packageName); } getContextForPackage(packageName); } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Can't preload package", e); } } Log.i(TAG, "Sandbox #" + mID + ": preload complete"); } }); return mBinder; }