List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:org.peterbaldwin.vlcremote.app.PlaybackActivity.java
@Override protected void onNewIntent(Intent intent) { String host = intent.getStringExtra(Intents.EXTRA_REMOTE_HOST); if (host != null) { int port = intent.getIntExtra(Intents.EXTRA_REMOTE_PORT, 8080); String authority = host + ":" + port; changeServer(authority);//from ww w. ja v a 2s.c o m } String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action) || Intents.ACTION_REMOTE_VIEW.equals(action) || Intents.ACTION_VIEW.equals(action)) { Uri data = intent.getData(); if (data != null) { changeInput(data.toString()); } } else if (Intent.ACTION_SEARCH.equals(action)) { String input = intent.getStringExtra(SearchManager.QUERY); changeInput(input); } }
From source file:com.abc.driver.TruckActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.truck);//from w w w . j a v a 2s . co m initView(); initData(); Intent intent = getIntent(); String newMobile = intent.getStringExtra(CellSiteConstants.TRUCK_MOBILE_NUM); if (newMobile != null) { app.getUser().getMyTruck().setMobileNum(newMobile); } Log.d(TAG, "newMobile = " + newMobile); }
From source file:by.zatta.pilight.connection.ConnectionService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { //??//from www . j a v a 2s. c o m sendMessageToUI(MSG_SET_STATUS, mCurrentNotif.name()); if (intent.hasExtra("command") && isConnectionUp) { Server.CONNECTION .sentCommand("{\"message\":\"send\",\"code\":{" + intent.getStringExtra("command") + "}}"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(aCtx); boolean useService = prefs.getBoolean("useService", true); if (!useService) { if (mWM == null || !mWM.isAlive()) { mWM = new WriteMonitor(); mWM.setName("WriteMonitor"); mWM.start(); } } } return START_STICKY; }
From source file:com.dnielfe.manager.Browser.java
private void initDirectory(Bundle savedInstanceState, Intent intent) { String defaultdir;// w w w . j a v a2 s . c o m if (savedInstanceState != null) { // get directory when you rotate your phone defaultdir = savedInstanceState.getString("location"); } else { try { File dir = new File(intent.getStringExtra(EXTRA_SHORTCUT)); if (dir.exists() && dir.isDirectory()) { defaultdir = dir.getAbsolutePath(); } else { if (dir.exists() && dir.isFile()) listItemAction(dir); // you need to call it when shortcut-dir not exists defaultdir = Settings.defaultdir; } } catch (Exception e) { defaultdir = Settings.defaultdir; } } File dir = new File(defaultdir); if (dir.exists() && dir.isDirectory()) navigateTo(dir.getAbsolutePath()); }
From source file:net.evecom.androidecssp.activity.taskresponse.TaskAddActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case R.layout.people_search_at: // BaseModel personinfo = (BaseModel) getData("personinfo", data); if (null != personinfo) { valueKeyMap.put("taskpersonid", personinfo.getStr("id")); taskpersonView.setText(personinfo.getStr("name")); }/*from ww w .j a v a 2s. c om*/ break; case R.layout.tree_list_at: // String id = data.getStringExtra("nodeid"); String name = data.getStringExtra("nodeName"); if (null != id) { valueKeyMap.put("taskdeptid", id); taskdeptView.setText(name); } break; case 2: break; default: break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.llf.android.launcher3.InstallShortcutReceiver.java
@Override public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;/*from w w w . j a v a2 s .c o m*/ } 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 = 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 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:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? phoneNum = openActivity.getStringExtra("phoneNum"); // get the phonenumber submitted in the last activity selectedService = openActivity.getIntExtra("selectedService", 1); // array position of selected service in last activity serviceIdItems = openActivity.getStringArrayListExtra("serviceIdItems"); // arraylist of service id's (in database) serviceNameItems = openActivity.getStringArrayListExtra("serviceNameItems"); // arraylist of service names serviceDescItems = openActivity.getStringArrayListExtra("serviceDescItems"); // arraylist of service descriptions voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ // TODO Auto-generated method stub super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);/* ww w .jav a2 s . c o m*/ } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_subscription_final); if (!isInDebugMode) { try { //SmsManager smsManager = SmsManager.getDefault(); //smsManager.sendTextMessage(phoneNumber, null, SMSMessage, null, null); Toast.makeText(getApplicationContext(), "Thanks for subscribing!", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS failed, please try again later!", Toast.LENGTH_SHORT) .show(); e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Debug mode - no SMS sent to save money :)", Toast.LENGTH_SHORT) .show(); } // Set up sound playback initMediaPlayer(); }
From source file:com.aidy.launcher3.ui.receiver.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;//from w ww . ja va2 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 = 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 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.example.lilach.alsweekathon_new.MainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_SELECT_DEVICE: //When the DeviceListActivity return, with the selected device address if (resultCode == Activity.RESULT_OK && data != null) { String deviceAddress = data.getStringExtra(BluetoothDevice.EXTRA_DEVICE); mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(deviceAddress); // Log.d(TAG, "... onActivityResultdevice.address==" + mDevice + "mserviceValue" + mService); ((TextView) findViewById(R.id.deviceName)).setText(mDevice.getName() + " - connecting"); // mService.connect(deviceAddress); }//from www.j a v a2 s . c om break; case REQUEST_ENABLE_BT: // When the request to enable Bluetooth returns if (resultCode == Activity.RESULT_OK) { Toast.makeText(this, "Bluetooth has turned on ", Toast.LENGTH_SHORT).show(); } else { // User did not enable Bluetooth or an error occurred Log.d(TAG, "BT not enabled"); Toast.makeText(this, "Problem in BT Turning ON ", Toast.LENGTH_SHORT).show(); finish(); } break; default: Log.e(TAG, "wrong request code"); break; } }
From source file:com.amaze.carbonfilemanager.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { Bundle b = new Bundle(); String file = intent.getStringExtra(KEY_PATH_ZIP); String extractPath = intent.getStringExtra(KEY_PATH_EXTRACT); if (extractPath != null) { // a custom dynamic path to extract files to epath = extractPath;//ww w.ja v a2 s . c om } else { epath = PreferenceManager.getDefaultSharedPreferences(this).getString(KEY_PATH_EXTRACT, file); } mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); entries = intent.getStringArrayListExtra(KEY_ENTRIES_ZIP); b.putString(KEY_PATH_ZIP, file); totalSize = getTotalSize(file); progressHandler = new ProgressHandler(1, totalSize); progressHandler.setProgressListener(new ProgressHandler.ProgressListener() { @Override public void onProgressed(String fileName, int sourceFiles, int sourceProgress, long totalSize, long writtenSize, int speed) { publishResults(startId, fileName, sourceFiles, sourceProgress, totalSize, writtenSize, speed, false); } }); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(cd); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.extracting)) .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_zip_box_grey600_36dp); startForeground(Integer.parseInt("123" + startId), mBuilder.build()); new DoWork().execute(b); return START_STICKY; }