List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:com.easemob.chatui.DemoHXSDKHelper.java
/** * ?/*from w ww . j a v a2 s.c om*/ * ?UI???UI??????? * activityList.size() <= 0 ????????Activity Stack */ protected void initEventListener() { eventListener = new EMEventListener() { private BroadcastReceiver broadCastReceiver = null; @Override public void onEvent(EMNotifierEvent event) { EMMessage message = null; if (event.getData() instanceof EMMessage) { message = (EMMessage) event.getData(); EMLog.d(TAG, "receive the event : " + event.getEvent() + ",id : " + message.getMsgId()); } switch (event.getEvent()) { case EventNewMessage: //????UI,???? if (activityList.size() <= 0) { HXSDKHelper.getInstance().getNotifier().onNewMsg(message); } break; case EventOfflineMessage: if (activityList.size() <= 0) { EMLog.d(TAG, "received offline messages"); List<EMMessage> messages = (List<EMMessage>) event.getData(); HXSDKHelper.getInstance().getNotifier().onNewMesg(messages); } break; case EventNewCMDMessage: { EMLog.d(TAG, "??"); //??body CmdMessageBody cmdMsgBody = (CmdMessageBody) message.getBody(); final String action = cmdMsgBody.action;//?action //? ? //message.getStringAttribute(""); EMLog.d(TAG, String.format("??action:%s,message:%s", action, message.toString())); final String str = appContext.getString(R.string.receive_the_passthrough); final String CMD_TOAST_BROADCAST = "easemob.demo.cmd.toast"; IntentFilter cmdFilter = new IntentFilter(CMD_TOAST_BROADCAST); if (broadCastReceiver == null) { broadCastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Toast.makeText(appContext, intent.getStringExtra("cmd_value"), Toast.LENGTH_SHORT) .show(); } }; // appContext.registerReceiver(broadCastReceiver, cmdFilter); } Intent broadcastIntent = new Intent(CMD_TOAST_BROADCAST); broadcastIntent.putExtra("cmd_value", str + action); appContext.sendBroadcast(broadcastIntent, null); break; } case EventDeliveryAck: message.setDelivered(true); break; case EventReadAck: message.setAcked(true); break; // add other events in case you are interested in default: break; } } }; EMChatManager.getInstance().registerEventListener(eventListener); EMChatManager.getInstance().addChatRoomChangeListener(new EMChatRoomChangeListener() { private final static String ROOM_CHANGE_BROADCAST = "easemob.demo.chatroom.changeevent.toast"; private final IntentFilter filter = new IntentFilter(ROOM_CHANGE_BROADCAST); private boolean registered = false; private void showToast(String value) { if (!registered) { // appContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(appContext, intent.getStringExtra("value"), Toast.LENGTH_SHORT).show(); } }, filter); registered = true; } Intent broadcastIntent = new Intent(ROOM_CHANGE_BROADCAST); broadcastIntent.putExtra("value", value); appContext.sendBroadcast(broadcastIntent, null); } @Override public void onChatRoomDestroyed(String roomId, String roomName) { showToast(" room : " + roomId + " with room name : " + roomName + " was destroyed"); Log.i("info", "onChatRoomDestroyed=" + roomName); } @Override public void onMemberJoined(String roomId, String participant) { showToast("member : " + participant + " join the room : " + roomId); Log.i("info", "onmemberjoined=" + participant); } @Override public void onMemberExited(String roomId, String roomName, String participant) { showToast("member : " + participant + " leave the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberExited=" + participant); } @Override public void onMemberKicked(String roomId, String roomName, String participant) { showToast("member : " + participant + " was kicked from the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberKicked=" + participant); } }); }
From source file:com.ddj.launcher2.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;//from w w w . j a v a 2s. com } Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall back to activity name // if not supplied String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (name == null) { try { PackageManager pm = context.getPackageManager(); ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0); name = info.loadLabel(pm).toString(); } catch (PackageManager.NameNotFoundException nnfe) { return; } } Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet boolean launcherNotLoaded = LauncherModel.getCellCountX() <= 0 || LauncherModel.getCellCountY() <= 0; PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; if (mUseInstallQueue || launcherNotLoaded) { String spKey = LauncherUtil.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); } else { processInstallShortcut(context, info); } }
From source file:org.runnerup.export.RunKeeperSynchronizer.java
@Override public Status getAuthResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { String authConfig = data.getStringExtra(DB.ACCOUNT.AUTH_CONFIG); try {/* w w w .j ava 2 s . com*/ access_token = new JSONObject(authConfig).getString("access_token"); return Status.OK; } catch (JSONException e) { Log.e(Constants.LOG, e.getMessage()); } } return Status.ERROR; }
From source file:luan.com.flippit.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { mContext = this; mPrefs = getSharedPreferences(mContext.getPackageName(), Context.MODE_PRIVATE); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(this); activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); Bundle extras = intent.getExtras();// www . jav a 2s. c o m GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String message = intent.getStringExtra("message"); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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)) { manageNotification(message); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:org.sigimera.app.android.GCMIntentService.java
@Override protected final void onMessage(final Context context, final Intent message) { final Intent msg = message; this.mainThreadHandler.post(new Runnable() { public void run() { ApplicationController controller = ApplicationController.getInstance(); controller.init(getApplicationContext(), getSharedPreferences(Constants.PREFS_NAME, 0), null); String authToken = controller.getSharedPreferences().getString("auth_token", null); final String type = msg.getStringExtra("sig_message_type"); if (type.equalsIgnoreCase("NEW_CRISIS")) { /**/* w ww . j ava 2 s . c o m*/ * XXX: Blocks UI: Shift this code into a separate * background thread */ Crisis crisis = PersistanceController.getInstance().getCrisis(authToken, msg.getStringExtra("crisis_id")); StringBuffer message = new StringBuffer(); if (crisis != null) { message.append(crisis.getID()); message.append(" was stored successfully!"); } else { message.append("Not able to get crisis!"); } Toast.makeText(getApplicationContext(), message.toString(), Toast.LENGTH_LONG).show(); } else if (type.equalsIgnoreCase("PING")) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); Intent notificationIntent = new Intent(); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new NotificationCompat.Builder(getApplicationContext()) .setContentTitle("Sigimera PING!") .setContentText("Congratulations, push notifcation received!") .setSmallIcon(R.drawable.sigimera_logo).setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL).setContentIntent(contentIntent).build(); mNotificationManager.notify(Constants.PING_ID, notification); } else if (type.equalsIgnoreCase("CRISIS_ALERT")) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); /** * XXX: Not working with random ID. That makes always the * latest notification clickable, but not the older ones. */ int notificationID = new Random().nextInt(); Intent notificationIntent = new Intent(getApplicationContext(), CrisisAlertActivity.class); notificationIntent.putExtra("notification_id", notificationID); notificationIntent.putExtra("crisis_id", msg.getStringExtra("crisis_id")); notificationIntent.putExtra("crisis_type", msg.getStringExtra("crisis_type")); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new NotificationCompat.Builder(getApplicationContext()) .setContentTitle("CRISIS ALERT!") .setContentText("Crisis found: " + msg.getStringExtra("crisis_id")) .setSmallIcon(R.drawable.alert_red).setOngoing(true).setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL).setContentIntent(contentIntent).build(); mNotificationManager.notify(notificationID, notification); } else if (type.equalsIgnoreCase("SHARED_CRISIS")) { Intent intent = new Intent(GCMIntentService.this, CrisisActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Constants.CRISIS_ID, msg.getStringExtra("crisis_id")); intent.putExtra(Constants.WINDOW_TYPE, Constants.WINDOW_TYPE_SHARED_CRISIS); startActivity(intent); } else if (type.equalsIgnoreCase("UNREGISTER_DEVICE")) { GCMRegistrar.unregister(ApplicationController.getInstance().getApplicationContext()); } else if (type.equalsIgnoreCase("REFRESH")) { LocationUpdaterHttpHelper locUpdater = new LocationUpdaterHttpHelper(); Location loc = LocationController.getInstance().getLastKnownLocation(); if (loc != null) { String latitude = loc.getLatitude() + ""; String longitude = loc.getLongitude() + ""; if (authToken != null) { locUpdater.execute(authToken, latitude, longitude); } } else { // TODO: Notify the user that the update location flow // has not worked. } } } }); }
From source file:zxing.util.CaptureActivity.java
License:asdf
/** * A valid barcode has been found, so give an indication of success and show * the results./*from ww w .j a va2 s. co m*/ * * @param rawResult * The contents of the barcode. * @param scaleFactor * amount by which thumbnail was scaled * @param barcode * A greyscale bitmap of the camera data which was decoded. */ public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) { inactivityTimer.onActivity(); //lastResult = rawResult; String url = "http://192.168.1.105:8080/ExTraceWebService_war/REST/Domain"; beepManager.playBeepSoundAndVibrate(); String resultString = rawResult.getText(); Intent mIntent = getIntent(); if (mIntent.getStringExtra("Action").equals("Pkg")) { switch (Integer.parseInt(mIntent.getStringExtra("role").toString().substring(0, 1))) { //( // case 1: Log.i("teasdfjsadf", mIntent.getStringExtra("role").toString()); if (resultString.startsWith("1")) { url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); startOnePkgExp(url);// // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else if (resultString.startsWith("8")) { url = url + "/dispatchExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); changePkgToStatus4(url);// break; } else { break; } // case 2: if (resultString.startsWith("8")) { url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); startOnePkgExp(url);// // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } break; // case 3: if (resultString.startsWith("1")) { url = url + "/packTransPackage/PackageID/" + "8001" + "/ExpressID/" + resultString; // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else if (resultString.startsWith("8")) { url = url + "/unpackTransPackage/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); break; } else { break; } } } else if (mIntent.getStringExtra("Action").equals("exp")) { // switch (Integer.parseInt(mIntent.getStringExtra("role"))) { case 1: //finsh(); break; case 2: if (resultString.startsWith("8")) { url = url + "/unpackTransPackage/" + "8001"; // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else { } //finsh(); break; // case 3: } } drawResultPoints(barcode, scaleFactor, rawResult); statusView.setVisibility(View.GONE); viewfinderView.setVisibility(View.GONE); resultView.setVisibility(View.VISIBLE); ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view); if (barcode == null) { barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.launcher_icon)); } else { barcodeImageView.setImageBitmap(barcode); } ParsedResult result = ResultParser.parseResult(rawResult); String contents = result.getDisplayResult().replace("\r", ""); CharSequence displayContents = contents; lastResult = contents; TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view); contentsTextView.setText(displayContents); int scaledSize = Math.max(22, 32 - displayContents.length() / 4); contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize); }
From source file:edu.cens.loci.ui.PlaceListActivity.java
/** * USE CASES://www . j a v a 2 s.com * * 1. DEFAULT : * list places and when selected, ACTION_VIEW * * ACTION ... send ACTION_VIEW content://places/pid * SHOW ... * - Suggested places ... add "View GPS Places" * - Registered places ... * - Blocked places ... * - Filter by tag ... * * 2. INSERT_OR_EDIT : * list "create a new place" and "registered" places, when selected, ACTION_EDIT * * ACTION ... send ACTION_EDIT content://places/pid or ACTION_INSERT content://places * - show all suggested/registered/blocked places * SHOW... * - "create a new place" and "registered places" * * 3. PICK : * list places and when selected, return with a uri. * * ACTION ... return a data URL back to the caller * SHOW... * * 4. SEARCH : * TBD * */ @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.place_list); // Resolve the intent final Intent intent = getIntent(); String title = intent.getStringExtra(UI.TITLE_EXTRA_KEY); if (title != null) { setTitle(title); } String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { mMode = MODE_VIEW; } else if (Intents.UI.ACTION_INSERT.equals(action)) { mMode = MODE_INSERT; } else if (Intents.UI.ACTION_CREATE_OR_ADDTO_FROM_SUGGESTED_PLACE.equals(action)) { mMode = MODE_REGISTER_SUGGESTED; } else if (Intent.ACTION_PICK.equals(action)) { mMode = MODE_PICK; } MyLog.i(LociConfig.D.UI.DEBUG, TAG, String.format("List: mode=%d (%s)", mMode, action)); Bundle extras = intent.getExtras(); if (extras != null) { if (extras.containsKey(Intents.UI.FILTER_STATE_EXTRA_KEY)) mFilterState = extras.getInt(Intents.UI.FILTER_STATE_EXTRA_KEY); if (extras.containsKey(Intents.UI.FILTER_TYPE_EXTRA_KEY)) mFilterType = extras.getInt(Intents.UI.FILTER_TYPE_EXTRA_KEY); if (extras.containsKey(Intents.UI.FILTER_TAG_EXTRA_KEY)) mFilterTag = extras.getString(Intents.UI.FILTER_TAG_EXTRA_KEY); if (extras.containsKey(Intents.UI.LIST_ORDER_EXTRA_KEY)) mListOrder = extras.getInt(Intents.UI.LIST_ORDER_EXTRA_KEY); } mDbUtils = new LociDbUtils(this); }
From source file:com.battlelancer.seriesguide.api.SeriesGuideExtension.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;/*from w w w . j a v a 2 s .c om*/ } String action = intent.getAction(); if (ACTION_SUBSCRIBE.equals(action)) { // just subscribing or unsubscribing handleSubscribe((ComponentName) intent.getParcelableExtra(EXTRA_SUBSCRIBER_COMPONENT), intent.getStringExtra(EXTRA_TOKEN)); } else if (ACTION_UPDATE.equals(action)) { // subscriber requests an updated action if (intent.hasExtra(EXTRA_ENTITY_IDENTIFIER) && intent.hasExtra(EXTRA_EPISODE)) { handleEpisodeRequest(intent.getIntExtra(EXTRA_ENTITY_IDENTIFIER, 0), intent.getBundleExtra(EXTRA_EPISODE)); } } }
From source file:fr.eyal.lib.data.service.DataLibService.java
@SuppressWarnings("unchecked") @Override/*from w w w. j av a 2 s. co m*/ protected void onHandleIntent(final Intent intent) { final int processorType = intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1); Out.d(TAG, "onHandleIntent"); // String userAgent = intent.getStringExtra(INTENT_EXTRA_USER_AGENT); final DataLibRequest request = new DataLibRequest(); DataLibWebConfig.applyToRequest(request, DataLibWebConfig.getInstance()); //we apply a default configuration for the request //we get the action data request.url = intent.getStringExtra(INTENT_EXTRA_URL); request.params = intent.getParcelableExtra(INTENT_EXTRA_PARAMS); request.parseType = intent.getIntExtra(INTENT_EXTRA_PARSE_TYPE, DataLibRequest.PARSE_TYPE_SAX_XML); //we eventually add the complex options Object complexOptions = intent.getSerializableExtra(INTENT_EXTRA_COMPLEX_OPTIONS); if (complexOptions instanceof ComplexOptions) request.complexOptions = (ComplexOptions) complexOptions; request.context = getApplicationContext(); //we get the options to apply int option = intent.getIntExtra(INTENT_EXTRA_REQUEST_OPTION, DataLibRequest.OPTION_NO_OPTION); DataLibWebConfig.applyToRequest(request, option, true); //we add the intent request.intent = intent; try { if (processorType == COOKIES_FLUSH) this.flushCookies(); else { //we launch the processor on a daughter class launchProcessor(processorType, request); } } catch (final Exception e) { Out.e(TAG, "Erreur", e); final BusinessResponse response = new BusinessResponse(); response.status = BusinessResponse.STATUS_ERROR; response.statusMessage = Log.getStackTraceString(e); sendResult(request, response, response.status); } }
From source file:com.netpace.expressit.activity.UploadVideoStoryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_upload_video_story); getSupportActionBar().setTitle("retake"); getSupportActionBar().setDisplayShowHomeEnabled(false); Intent intent = getIntent(); isGalleryVideo = intent.getBooleanExtra("isGalleryVideo", false); if (!isGalleryVideo) { videoMedia = (ADProcessedVideoMedia) intent.getSerializableExtra(VIDEO_PATH); video_filePath = videoMedia.getOutputFile().getPath(); } else {// www . j a va 2 s . co m video_filePath = intent.getStringExtra(VIDEO_PATH); } Point screenDimenions = getDisplayDimensions(); videoView = (ADCustomVideoView) findViewById(R.id.videoView); videoView.setDimensions(screenDimenions.x, screenDimenions.y - screenDimenions.y / 3); videoView.setVideoURI(Uri.parse(video_filePath)); playBtn = (Button) findViewById(R.id.playButton); playBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { playVideoClip(); } }); titleTextView = (TypefaceEditText) findViewById(R.id.story_title_txt_field); button_save = (Button) findViewById(R.id.shareButton); button_save.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Util.showToast(R.string.in_progress); } }); if (!isGalleryVideo) { videoSlicePanal = (LinearLayout) findViewById(R.id.videoSlicePanal); String sessionDirPath = videoMedia.getDirectoryPath() + "/"; File dir = new File(sessionDirPath); String[] fileNames = dir.list(); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(140, 140); lp.setMargins(3, 3, 3, 3); for (int i = 0; i < fileNames.length; i++) { if (fileNames[i] == "output.mp4") continue; String filePath = sessionDirPath + fileNames[i]; ADCustomVideoView vv = new ADCustomVideoView(this); vv.setLayoutParams(lp); vv.setDimensions(140, 140); vv.setVideoURI(Uri.parse(filePath)); videoSlicePanal.addView(vv); } } }