List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:com.commonsware.cwac.locpoll.demo.LocationReceiver.java
@Override public void onReceive(Context context, Intent intent) { mContext = context;// w ww .j a v a 2s . com File log = new File(Environment.getExternalStorageDirectory(), "LocationLog.txt"); try { BufferedWriter out = new BufferedWriter(new FileWriter(log.getAbsolutePath(), log.exists())); out.write(new Date().toString()); out.write(" : "); Bundle b = intent.getExtras(); loc = (Location) b.get(LocationPoller.EXTRA_LOCATION); String msg; if (loc == null) { loc = (Location) b.get(LocationPoller.EXTRA_LASTKNOWN); if (loc == null) { msg = intent.getStringExtra(LocationPoller.EXTRA_ERROR); } else { msg = "TIMEOUT, lastKnown=" + loc.toString(); } } else { msg = loc.toString(); Log.d("Location Poller", msg); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_HSDPA)) { Log.d("Type", "3g");// for 3g HSDPA networktype will be return as // per testing(real) in device with 3g enable data // and speed will also matters to decide 3g network type type = 2; } else if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_HSPAP)) { Log.d("Type", "4g"); // /No specification for the 4g but from wiki // i found(HSPAP used in 4g) // http://goo.gl/bhtVT type = 3; } else if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_GPRS)) { Log.d("Type", "GPRS"); type = 1; } else if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE)) { Log.d("Type", "EDGE 2g"); type = 0; } /* Update the listener, and start it */ MyListener = new MyPhoneStateListener(); Tel = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } if (msg == null) { msg = "Invalid broadcast received!"; } out.write(msg); out.write("\n"); out.close(); } catch (IOException e) { Log.e(getClass().getName(), "Exception appending to log file", e); } }
From source file:com.android.launcher4.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;//from ww w.j a v a 2 s .com } if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0)); 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 = ensureValidName(context, intent, data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)).toString(); 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 LauncherAppState.setApplicationContext(context.getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); boolean launcherNotLoaded = (app.getDynamicGrid() == null); PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); if (!mUseInstallQueue && !launcherNotLoaded) { flushInstallQueue(context); } }
From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java
/** * Imports notes and notebooks from Springpad exported archive */*from ww w. j a v a2 s. com*/ * @param intent */ synchronized private void importDataFromSpringpad(Intent intent) { String backupPath = intent.getStringExtra(EXTRA_SPRINGPAD_BACKUP); Importer importer = new Importer(); try { importer.setZipProgressesListener(percentage -> mNotificationsHelper .setMessage(getString(com.dycody.android.idealnote.R.string.extracted) + " " + percentage + "%") .show()); importer.doImport(backupPath); // Updating notification updateImportNotification(importer); } catch (ImportException e) { new NotificationsHelper(this) .createNotification(com.dycody.android.idealnote.R.drawable.ic_emoticon_sad_white_24dp, getString(com.dycody.android.idealnote.R.string.import_fail) + ": " + e.getMessage(), null) .setLedActive().show(); return; } List<SpringpadElement> elements = importer.getSpringpadNotes(); // If nothing is retrieved it will exit if (elements == null || elements.size() == 0) { return; } // These maps are used to associate with post processing notes to categories (notebooks) HashMap<String, Category> categoriesWithUuid = new HashMap<>(); // Adds all the notebooks (categories) for (SpringpadElement springpadElement : importer.getNotebooks()) { Category cat = new Category(); cat.setName(springpadElement.getName()); cat.setColor(String.valueOf(Color.parseColor("#F9EA1B"))); DbHelper.getInstance().updateCategory(cat); categoriesWithUuid.put(springpadElement.getUuid(), cat); // Updating notification importedSpringpadNotebooks++; updateImportNotification(importer); } // And creates a default one for notes without notebook Category defaulCategory = new Category(); defaulCategory.setName("Springpad"); defaulCategory.setColor(String.valueOf(Color.parseColor("#F9EA1B"))); DbHelper.getInstance().updateCategory(defaulCategory); // And then notes are created Note note; Attachment mAttachment = null; Uri uri; for (SpringpadElement springpadElement : importer.getNotes()) { note = new Note(); // Title note.setTitle(springpadElement.getName()); // Content dependent from type of Springpad note StringBuilder content = new StringBuilder(); content.append( TextUtils.isEmpty(springpadElement.getText()) ? "" : Html.fromHtml(springpadElement.getText())); content.append( TextUtils.isEmpty(springpadElement.getDescription()) ? "" : springpadElement.getDescription()); // Some notes could have been exported wrongly if (springpadElement.getType() == null) { Toast.makeText(this, getString(com.dycody.android.idealnote.R.string.error), Toast.LENGTH_SHORT) .show(); continue; } if (springpadElement.getType().equals(SpringpadElement.TYPE_VIDEO)) { try { content.append(System.getProperty("line.separator")) .append(springpadElement.getVideos().get(0)); } catch (IndexOutOfBoundsException e) { content.append(System.getProperty("line.separator")).append(springpadElement.getUrl()); } } if (springpadElement.getType().equals(SpringpadElement.TYPE_TVSHOW)) { content.append(System.getProperty("line.separator")) .append(TextUtils.join(", ", springpadElement.getCast())); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOK)) { content.append(System.getProperty("line.separator")).append("Author: ") .append(springpadElement.getAuthor()).append(System.getProperty("line.separator")) .append("Publication date: ").append(springpadElement.getPublicationDate()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_RECIPE)) { content.append(System.getProperty("line.separator")).append("Ingredients: ") .append(springpadElement.getIngredients()).append(System.getProperty("line.separator")) .append("Directions: ").append(springpadElement.getDirections()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOKMARK)) { content.append(System.getProperty("line.separator")).append(springpadElement.getUrl()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BUSINESS) && springpadElement.getPhoneNumbers() != null) { content.append(System.getProperty("line.separator")).append("Phone number: ") .append(springpadElement.getPhoneNumbers().getPhone()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_PRODUCT)) { content.append(System.getProperty("line.separator")).append("Category: ") .append(springpadElement.getCategory()).append(System.getProperty("line.separator")) .append("Manufacturer: ").append(springpadElement.getManufacturer()) .append(System.getProperty("line.separator")).append("Price: ") .append(springpadElement.getPrice()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_WINE)) { content.append(System.getProperty("line.separator")).append("Wine type: ") .append(springpadElement.getWine_type()).append(System.getProperty("line.separator")) .append("Varietal: ").append(springpadElement.getVarietal()) .append(System.getProperty("line.separator")).append("Price: ") .append(springpadElement.getPrice()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_ALBUM)) { content.append(System.getProperty("line.separator")).append("Artist: ") .append(springpadElement.getArtist()); } for (SpringpadComment springpadComment : springpadElement.getComments()) { content.append(System.getProperty("line.separator")).append(springpadComment.getCommenter()) .append(" commented at 0").append(springpadComment.getDate()).append(": ") .append(springpadElement.getArtist()); } note.setContent(content.toString()); // Checklists if (springpadElement.getType().equals(SpringpadElement.TYPE_CHECKLIST)) { StringBuilder sb = new StringBuilder(); String checkmark; for (SpringpadItem mSpringpadItem : springpadElement.getItems()) { checkmark = mSpringpadItem.getComplete() ? it.feio.android.checklistview.interfaces.Constants.CHECKED_SYM : it.feio.android.checklistview.interfaces.Constants.UNCHECKED_SYM; sb.append(checkmark).append(mSpringpadItem.getName()) .append(System.getProperty("line.separator")); } note.setContent(sb.toString()); note.setChecklist(true); } // Tags String tags = springpadElement.getTags().size() > 0 ? "#" + TextUtils.join(" #", springpadElement.getTags()) : ""; if (note.isChecklist()) { note.setTitle(note.getTitle() + tags); } else { note.setContent(note.getContent() + System.getProperty("line.separator") + tags); } // Address String address = springpadElement.getAddresses() != null ? springpadElement.getAddresses().getAddress() : ""; if (!TextUtils.isEmpty(address)) { try { double[] coords = GeocodeHelper.getCoordinatesFromAddress(this, address); note.setLatitude(coords[0]); note.setLongitude(coords[1]); } catch (IOException e) { Log.e(Constants.TAG, "An error occurred trying to resolve address to coords during Springpad import"); } note.setAddress(address); } // Reminder if (springpadElement.getDate() != null) { note.setAlarm(springpadElement.getDate().getTime()); } // Creation, modification, category note.setCreation(springpadElement.getCreated().getTime()); note.setLastModification(springpadElement.getModified().getTime()); // Image String image = springpadElement.getImage(); if (!TextUtils.isEmpty(image)) { try { File file = StorageHelper.createNewAttachmentFileFromHttp(this, image); uri = Uri.fromFile(file); String mimeType = StorageHelper.getMimeType(uri.getPath()); mAttachment = new Attachment(uri, mimeType); } catch (MalformedURLException e) { uri = Uri.parse(importer.getWorkingPath() + image); mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true); } catch (IOException e) { Log.e(Constants.TAG, "Error retrieving Springpad online image"); } if (mAttachment != null) { note.addAttachment(mAttachment); } mAttachment = null; } // Other attachments for (SpringpadAttachment springpadAttachment : springpadElement.getAttachments()) { // The attachment could be the image itself so it's jumped if (image != null && image.equals(springpadAttachment.getUrl())) continue; if (TextUtils.isEmpty(springpadAttachment.getUrl())) { continue; } // Tries first with online images try { File file = StorageHelper.createNewAttachmentFileFromHttp(this, springpadAttachment.getUrl()); uri = Uri.fromFile(file); String mimeType = StorageHelper.getMimeType(uri.getPath()); mAttachment = new Attachment(uri, mimeType); } catch (MalformedURLException e) { uri = Uri.parse(importer.getWorkingPath() + springpadAttachment.getUrl()); mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true); } catch (IOException e) { Log.e(Constants.TAG, "Error retrieving Springpad online image"); } if (mAttachment != null) { note.addAttachment(mAttachment); } mAttachment = null; } // If the note has a category is added to the map to be post-processed if (springpadElement.getNotebooks().size() > 0) { note.setCategory(categoriesWithUuid.get(springpadElement.getNotebooks().get(0))); } else { note.setCategory(defaulCategory); } // The note is saved DbHelper.getInstance().updateNote(note, false); ReminderHelper.addReminder(IdealNote.getAppContext(), note); // Updating notification importedSpringpadNotes++; updateImportNotification(importer); } // Delete temp data try { importer.clean(); } catch (IOException e) { Log.w(Constants.TAG, "Springpad import temp files not deleted"); } String title = getString(com.dycody.android.idealnote.R.string.data_import_completed); String text = getString(com.dycody.android.idealnote.R.string.click_to_refresh_application); createNotification(intent, this, title, text, null); }
From source file:net.niyonkuru.koodroid.service.SessionService.java
@Override public void onHandleIntent(Intent intent) { if (DEBUG)/*from w w w .ja va 2 s.c o m*/ Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")"); int request = intent.getIntExtra(EXTRA_REQUEST, REQUEST_LOGIN); if (request == REQUEST_LOGOUT) { logout(); return; } final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); final String email = intent.getStringExtra(EXTRA_EMAIL); final String password = intent.getStringExtra(EXTRA_PASSWORD); boolean broadcast = intent.getBooleanExtra(EXTRA_BROADCAST, false); /* totally ignore this request until full credentials are provided */ if (email == null || password == null) return; final long startLogin = System.currentTimeMillis(); final long lastLogin = mSettings.lastLogin(); /* if the last successful login is within the last 15 minutes */ if (startLogin - lastLogin <= DateUtils.MINUTE_IN_MILLIS * 15) { /* do a credentials check again the local data store */ if (email.equals(mSettings.email()) && password.equals(mSettings.password())) { if (broadcast) IntentUtils.callWidget(this, LOGIN_FINISHED); announce(receiver, STATUS_FINISHED); return; } } try { if (NetworkUtils.isConnected(this)) { /* announce to the caller that we are now running */ announce(receiver, STATUS_RUNNING); } else throw new ServiceException(getString(R.string.error_network_down)); if (mSettings.email() == null) { /* this is likely a new user */ Crittercism.leaveBreadcrumb(TAG + ": first_time_login"); } login(email, password); saveCookies(); if (DEBUG) Log.d(TAG, "login took " + (System.currentTimeMillis() - startLogin) + "ms"); } catch (IOException e) { if (DEBUG) Log.e(TAG, "Problem while logging in", e); /* if the exception was simply from an abort */ if (mPostRequest != null && mPostRequest.isAborted()) return; if (receiver != null) { // Pass back error to surface listener final Bundle bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } return; /* do not announce success below */ } if (broadcast) IntentUtils.callWidget(this, LOGIN_FINISHED); announce(receiver, STATUS_FINISHED); }
From source file:org.ohmage.auth.AuthenticatorActivity.java
@Override protected void onActivityResult(int requestCode, int responseCode, Intent intent) { switch (requestCode) { case GOOGLE_CODE_RESULT: if (responseCode == RESULT_OK) { String token = intent.getStringExtra("authtoken"); if (token != null) { useGoogleToken(token, false); return; }// ww w . j a va2s.co m } case REQUEST_CODE_PLUS_CLIENT_FRAGMENT: // Only show progress if the result failed indicating there was an error showProgress(responseCode == RESULT_OK); mPlusClientFragment.handleOnActivityResult(requestCode, responseCode, intent); break; } }
From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java
/** * Get the parameters from the message and create a notification from it. * @param context/*from ww w. j ava2s . com*/ * @param intent */ public void handleMessage(Context context, Intent intent) { try { registerResources(context); extractColors(context); FREContext ctxt = C2DMExtension.context; NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // icon is required for notification. // @see http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html int icon = notificationIcon; long when = System.currentTimeMillis(); // json string String parameters = intent.getStringExtra("parameters"); String facebookId = null; JSONObject object = null; if (parameters != null) { try { object = (JSONObject) new JSONTokener(parameters).nextValue(); } catch (Exception e) { Log.d(TAG, "cannot parse the object"); } } if (object != null && object.has("facebookId")) { facebookId = object.getString("facebookId"); } CharSequence tickerText = intent.getStringExtra("tickerText"); CharSequence contentTitle = intent.getStringExtra("contentTitle"); CharSequence contentText = intent.getStringExtra("contentText"); Intent notificationIntent = new Intent(context, Class.forName(context.getPackageName() + ".AppEntry")); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); RemoteViews contentView = new RemoteViews(context.getPackageName(), customLayout); contentView.setTextViewText(customLayoutTitle, contentTitle); contentView.setTextViewText(customLayoutDescription, contentText); contentView.setTextColor(customLayoutTitle, notification_text_color); contentView.setFloat(customLayoutTitle, "setTextSize", notification_title_size_factor * notification_text_size); contentView.setTextColor(customLayoutDescription, notification_text_color); contentView.setFloat(customLayoutDescription, "setTextSize", notification_description_size_factor * notification_text_size); if (facebookId != null) { Log.d(TAG, "bitmap not null"); CreateNotificationTask cNT = new CreateNotificationTask(); cNT.setParams(customLayoutImageContainer, NotifId, nm, notification, contentView); String src = "http://graph.facebook.com/" + facebookId + "/picture?type=normal"; URL url = new URL(src); cNT.execute(url); } else { Log.d(TAG, "bitmap null"); contentView.setImageViewResource(customLayoutImageContainer, customLayoutImage); notification.contentView = contentView; nm.notify(NotifId, notification); } NotifId++; if (ctxt != null) { parameters = parameters == null ? "" : parameters; ctxt.dispatchStatusEventAsync("COMING_FROM_NOTIFICATION", parameters); } } catch (Exception e) { Log.e(TAG, "Error activating application:", e); } }
From source file:com.example.android.bluetoothlegatt.DeviceControlActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); if (intent.hasExtra(EXTRAS_DEVICE_NAME)) { mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME); } else {/*w w w. j av a 2 s. c o m*/ Log.d(TAG, "No device name"); finish(); } if (intent.hasExtra(EXTRAS_DEVICE_ADDRESS)) { mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS); } else { Log.d(TAG, "No device address"); finish(); } if (intent.hasExtra(EXTRAS_CONNECTION_METHOD)) { String connectionMethod = intent.getStringExtra(EXTRAS_CONNECTION_METHOD); isBluetoothConnection = connectionMethod.equalsIgnoreCase(BLUETOOTH_METHOD); } else { Log.d(TAG, "No connection method."); finish(); } try { getActionBar().setTitle(mDeviceName); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); } catch (NullPointerException e) { Log.w(TAG, "NullPointerException when trying to getActionBar()."); } // Setup HTTP API for both cases // if (isBluetoothConnection): // send responses to server's requests. // else: send instructions to server. mRestAdapter = new RestAdapter.Builder().setEndpoint(RETROFIT_API_ENDPOINT) .setLogLevel(RestAdapter.LogLevel.FULL).build(); mClient = mRestAdapter.create(RetrofitResponseApi.class); if (isBluetoothConnection) { // Bind BluetoothLeService to this activity Intent gattServiceIntent = new Intent(this, BluetoothLeService.class); bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); mProgressBar = Util.setProgressBar(this); } else { setControlView(); } }
From source file:com.parse.CN1ParsePushBroadcastReceiver.java
@Override protected void onPushOpen(Context context, Intent intent) { /*// w w w . j a va2 s . c o m Adapted from ParsePushBroadcastReceiver. Main changes: 1. Adapted code for starting app activity since it caused problems (see comments towards the end of the method starting from line 'Original code' 2. Implemented necessary ParsePush callback to set push data in advance so that it will be available when the app activity is started/resumed */ // Send a Parse Analytics "push opened" event ParseAnalytics.trackAppOpenedInBackground(intent); JSONObject pushData = null; String uriString = null; try { pushData = new JSONObject(intent.getStringExtra(ParsePushBroadcastReceiver.KEY_PUSH_DATA)); uriString = pushData.optString("uri", null); } catch (JSONException e) { writeErrorLog("Unexpected JSONException when parsing " + "push data from opened notification: " + e); } writeDebugLog("Push opened: " + (pushData == null ? "<no payload>" : pushData.toString())); if (pushData != null) { // Forward payload so that it is available when app is opened via the push message ParsePush.handlePushOpen(pushData.toString(), CN1AndroidApplication.isAppInForeground()); writeDebugLog("Notified ParsePush of opened push notification"); } Class<? extends Activity> cls = getActivity(context, intent); Intent activityIntent; if (uriString != null) { writeDebugLog("Creating an intent to view URI: " + uriString); activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString)); } else { activityIntent = new Intent(context, cls); } activityIntent.putExtras(intent.getExtras()); activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Original code // /* // In order to remove dependency on android-support-library-v4 // The reason why we differentiate between versions instead of just using context.startActivity // for all devices is because in API 11 the recommended conventions for app navigation using // the back key changed. // */ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // TaskStackBuilderHelper.startActivities(context, cls, activityIntent); // } else { // context.startActivity(activityIntent); // } // The task stack builder approach causes only the title and a white (blank) screen // to be shown when the app is in the foreground and the push notification is // opened (see also problem report to CN1 support forum: https://groups.google.com/d/msg/codenameone-discussions/Z3F924j_BG4/7rn7v7oABwAJ) // As a result, the context.startActivity() approach is currently taken always. // Not sure yet if it has any undesirable side effects for sdk version // before JELLY_BEAN (actually HONEYCOMB (v3.0) according to TaskStackBuilder documentation // at: http://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.html. context.startActivity(activityIntent); }
From source file:eu.dirtyharry.androidopsiadmin.Main.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);// w w w. j a va 2s . co m PACKAGE_NAME = this.getPackageName(); try { VERSION_NAME = Main.this.getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Eula.show(Main.this, getString(R.string.gen_lang_prefix)); cl = new ChangeLog(this); if (cl.firstRun()) cl.getLogDialog().show(); // FirstTimeUsageDialog.show(Main.this,"main_test","main_test.accepted"); // new Functions().noPreferences(Main.this, // getString(R.string.gen_title_error), // getString(R.string.gen_setpreferences)); // public SharedPreferences preferences = // Main.this.getSharedPreferences( // getPackageName() + "_preferences", MODE_PRIVATE); // CookieSyncManager.createInstance(this); SharedPreferences preferences = Main.this.getSharedPreferences(getPackageName() + "_preferences", MODE_PRIVATE); serverip = preferences.getString("serverip", ""); serverport = preferences.getString("serverport", ""); serverusername = preferences.getString("serverusername", ""); serverpasswd = preferences.getString("serverpasswd", ""); vibrate = preferences.getBoolean("vibrate", true); customtags = preferences.getBoolean("qr_enable_custom_tags", false); String extra = ""; final Intent intent = getIntent(); if (intent.getAction().equals(SHORTCUT_ACTION)) { extra = intent.getStringExtra("shortcut"); } if (extra.equals(getString(R.string.la_allclients))) { getOpsiClientsTask(); } else if (extra.equals(getString(R.string.la_scanqr))) { Intent qrDroid = new Intent("la.droid.qr.scan"); qrDroid.putExtra("la.droid.qr.complete", true); try { startActivityForResult(qrDroid, GET_QR); } catch (ActivityNotFoundException activity) { Functions.qrDroidRequired(Main.this); } } }
From source file:edu.cnu.PowerTutor.ui.PowerViewer.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub switch (requestCode) { case 0://from w ww . j a v a 2 s.com if (resultCode == RESULT_OK) { SeletedUid = data.getIntExtra("uid", 0); SeletedPackageName = data.getStringExtra("package_name"); Toast.makeText(PowerViewer.this, "Extra Data: " + SeletedUid + " " + SeletedPackageName, Toast.LENGTH_SHORT).show(); // ? ? ?? ? ?? . // ? ?? ? ? . saveProgress(PROGRESS_MAX); // ? . // Thread?? ?? Server Thread?. processResultThread mProcessResultThread = new processResultThread(); // Thread . mProcessResultThread.start(); Log.d(TAG, "Thread start pass"); } break; } }