List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.vidinoti.pixlive.PixLive.java
protected void pluginInitialize() { startSDK(cordova.getActivity());/*from w w w . j av a2s . c o m*/ VDARSDKController.getInstance().setEnableCodesRecognition(true); VDARSDKController.getInstance().setActivity(cordova.getActivity()); VDARSDKController.getInstance().registerEventReceiver(this); VDARSDKController.getInstance().addNewAfterLoadingTask(new Runnable() { @Override public void run() { Intent intent = cordova.getActivity().getIntent(); if (intent != null && intent.getExtras() != null && intent.getExtras().getString("nid") != null) { VDARSDKController.getInstance().processNotification(intent.getExtras().getString("nid"), intent.getExtras().getBoolean("remote")); } } }); cordova.getActivity().runOnUiThread(new Runnable() { public void run() { if (touchView == null) { View v = webView.getView(); FrameLayout parent = ((FrameLayout) v.getParent()); parent.removeView(v); touchView = new TouchInterceptorView(cordova.getActivity()); touchView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); cordova.getActivity().setContentView(touchView); touchView.addView(v); v.setBackgroundColor(Color.TRANSPARENT); } } }); }
From source file:org.dvbviewer.controller.service.SyncService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { int intentFlags = intent.getIntExtra(ACTION_EXTRA, 0); Message msg;/*w w w . j ava2 s . c o m*/ switch (intentFlags) { case SYNC_CHANNELS: msg = mServiceHandler.obtainMessage(); msg.what = SYNC_CHANNELS; msg.arg1 = startId; msg.arg2 = flags; msg.setData(intent.getExtras()); mServiceHandler.sendMessage(msg); Log.i("ServiceStartArguments", "Sending: " + msg); break; case SYNC_EPG: msg = mServiceHandler.obtainMessage(); msg.what = SYNC_EPG; msg.arg1 = startId; msg.arg2 = flags; msg.setData(intent.getExtras()); mServiceHandler.sendMessage(msg); Log.i("ServiceStartArguments", "Sending: " + msg); // EpgSyncronizer epgSyncer = new EpgSyncronizer(); // epgSyncer.execute(intent); break; default: stopSelf(); break; } } else { // switch (startId) { // case mChannelSyncId: // // break; // // default: // break; // } } return START_REDELIVER_INTENT; }
From source file:com.github.socialc0de.gsw.android.MainActivity.java
/** * Handles the results from activities launched to select an account and to install Google Play * Services.//from w w w. j a v a 2 s .c om */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_ACCOUNT_PICKER: if (data != null && data.getExtras() != null) { String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME); if (accountName != null) { onSignedIn(accountName); } } else if (!SIGN_IN_REQUIRED) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.are_you_sure); alert.setMessage(R.string.not_all_features); alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startMainActivity(); } }); alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); } }); alert.show(); } break; case REQUEST_GOOGLE_PLAY_SERVICES: if (resultCode != Activity.RESULT_OK) { checkGooglePlayServicesAvailable(); } break; } if (requestCode == REQUEST_CODE_PAYMENT) { if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { try { Log.i(TAG, confirm.toJSONObject().toString(4)); Log.i(TAG, confirm.getPayment().toJSONObject().toString(4)); /** * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification * or consent completion. * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ * for more details. * * For sample mobile backend interactions, see * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend */ Toast.makeText(getApplicationContext(), "PaymentConfirmation info received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e(TAG, "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i(TAG, "The user canceled."); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) { if (resultCode == Activity.RESULT_OK) { PayPalAuthorization auth = data .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION); if (auth != null) { try { Log.i("FuturePaymentExample", auth.toJSONObject().toString(4)); String authorization_code = auth.getAuthorizationCode(); Log.i("FuturePaymentExample", authorization_code); Toast.makeText(getApplicationContext(), "Future Payment code received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i("FuturePaymentExample", "The user canceled."); } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { Log.i("FuturePaymentExample", "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) { if (resultCode == Activity.RESULT_OK) { PayPalAuthorization auth = data .getParcelableExtra(PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION); if (auth != null) { try { Log.i("ProfileSharingExample", auth.toJSONObject().toString(4)); String authorization_code = auth.getAuthorizationCode(); Log.i("ProfileSharingExample", authorization_code); Toast.makeText(getApplicationContext(), "Profile Sharing code received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e("ProfileSharingExample", "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i("ProfileSharingExample", "The user canceled."); } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { Log.i("ProfileSharingExample", "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } }
From source file:com.zapto.park.ParkActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); /*/*from w w w. j av a 2s.c om*/ * Once a user has typed in their ID to clock and pressed Done, * the Pad will close and save the user's clock-in information * in the database clock.db * */ if (resultCode == Activity.RESULT_OK && requestCode == ACTIVITY_RESULT_PAD) { Log.i(LOG_TAG, "onActivityResult()"); Bundle extras = data.getExtras(); String id = extras.getString("id"); //this clocks in the user employeeCheck(id, true); Log.i(LOG_TAG, "Result: " + id); } else { Log.i(LOG_TAG, "onActivityResult(). Problem!"); } }
From source file:my.home.lehome.service.SendMsgIntentService.java
private void saveAndNotify(Intent intent, String result) { Context context = getApplicationContext(); int rep_code = -1; String desc;// w w w.j a va 2 s .c om try { JSONObject jsonObject = new JSONObject(result); rep_code = jsonObject.getInt("code"); desc = jsonObject.getString("desc"); } catch (JSONException e) { e.printStackTrace(); desc = context.getString(R.string.chat_error_json); } Messenger messenger; if (intent.hasExtra("messenger")) messenger = (Messenger) intent.getExtras().get("messenger"); else messenger = null; Message repMsg = Message.obtain(); repMsg.what = MSG_END_SENDING; ChatItem item = intent.getParcelableExtra("pass_item"); ChatItem newItem = null; if (item != null) { if (rep_code == 200) { item.setState(Constants.CHATITEM_STATE_SUCCESS); DBStaticManager.updateChatItem(context, item); } else { if (rep_code == 415) { item.setState(Constants.CHATITEM_STATE_SUCCESS); } else { item.setState(Constants.CHATITEM_STATE_ERROR); } DBStaticManager.updateChatItem(context, item); newItem = new ChatItem(); newItem.setContent(desc); newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_ERROR); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } else { if (rep_code != 200) { Log.d(TAG, result); newItem = new ChatItem(); newItem.setContent(getString(R.string.loc_send_error) + ":" + desc); // TODO - not only loc report newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_SUCCESS); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } Log.d(TAG, "dequeue item: " + item); if (item == null) return; Bundle bundle = new Bundle(); bundle.putParcelable("item", item); if (newItem != null) bundle.putParcelable("new_item", newItem); bundle.putInt("rep_code", rep_code); 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_END); Intent newIntent = new Intent(ACTION_SEND_MSG_END); newIntent.putExtras(bundle); sendBroadcast(newIntent); } }
From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java
@Override protected void onActivityResult(int request_code, int result_code, Intent data) { super.onActivityResult(request_code, result_code, data); switch (request_code) { case ACTIVITY_FROM: if (result_code == RESULT_OK) { Bundle b = data.getExtras(); if (b != null) { String station = b.getString("station"); ((AutoCompleteTextView) findViewById(R.id.from_station_entry)).setText(station); }/* w w w . ja v a 2 s . co m*/ } break; case ACTIVITY_TO: if (result_code == RESULT_OK) { Bundle b = data.getExtras(); if (b != null) { String station = b.getString("station"); ((AutoCompleteTextView) findViewById(R.id.to_station_entry)).setText(station); } } break; } }
From source file:com.commonsware.android.tuning.downloader.Downloader.java
@Override public void onHandleIntent(Intent i) { HttpGet getMethod = new HttpGet(i.getData().toString()); int result = Activity.RESULT_CANCELED; try {/*from www . jav a2 s. com*/ ResponseHandler<byte[]> responseHandler = new ByteArrayResponseHandler(); byte[] responseBody = client.execute(getMethod, responseHandler); File output = new File(Environment.getExternalStorageDirectory(), i.getData().getLastPathSegment()); if (output.exists()) { output.delete(); } FileOutputStream fos = new FileOutputStream(output.getPath()); fos.write(responseBody); fos.close(); result = Activity.RESULT_OK; } catch (IOException e2) { Log.e(getClass().getName(), "Exception in download", e2); } Bundle extras = i.getExtras(); if (extras != null) { Messenger messenger = (Messenger) extras.get(EXTRA_MESSENGER); Message msg = Message.obtain(); msg.arg1 = result; try { messenger.send(msg); } catch (android.os.RemoteException e1) { Log.w(getClass().getName(), "Exception sending message", e1); } } }
From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java
@OnActivityResult(REQUEST_CODE_SELECT_FILE_TO_IMPORT) void onActivityResultSelectFileToImport(int resultCode, Intent data) { if (resultCode != RESULT_OK) { return;//w ww .j ava2 s . c o m } Bundle extras = data.getExtras(); String path = extras.getString(FileSelectorActivity.RESULT_INTENT_PATH); String filename = extras.getString(FileSelectorActivity.RESULT_INTENT_FILENAME); importCardsFrom(path + "/" + filename); }
From source file:eu.dirtyharry.androidopsiadmin.Main.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == GET_QR && resultCode == RESULT_OK) { contents = data.getExtras().getString("la.droid.qr.result"); if (checkQR(contents)) { try { pc = (JSONObject) new JSONTokener(contents).nextValue(); hosttocheck = pc.getString("dns"); } catch (JSONException e) { e.printStackTrace();/*ww w . j a v a 2s. c o m*/ } final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait), String.format(getString(R.string.pd_checkifopsiclientexists), hosttocheck), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { if (hostexistsinopsi && doit.equals("true")) { if (customtags) { Intent i = new Intent(Main.this, ShowBarcodeData.class); Bundle b = new Bundle(); b.putString("qrdata", contents); i.putExtras(b); startActivity(i); } else { Intent i = new Intent(Main.this, ShowOpsiClientOptions.class); Bundle b = new Bundle(); b.putString("qrdata", contents); i.putExtras(b); startActivity(i); } } else if (!hostexistsinopsi) { new Functions().msgBox(Main.this, getString(R.string.gen_title_error), String.format(getString(R.string.general_noopsihost), hosttocheck), false); } else { Toast.makeText(Main.this, String.format(getString(R.string.to_servernotrechable), serverip), Toast.LENGTH_LONG).show(); } dialog.dismiss(); } }; Thread checkUpdate = new Thread() { public void run() { Looper.prepare(); if (eu.dirtyharry.androidopsiadmin.Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) { doit = "true"; if (eu.dirtyharry.androidopsiadmin.Networking.checkIfHostExistsInOpsi(hosttocheck, serverip, serverport, serverusername, serverpasswd)) { hostexistsinopsi = true; } else { hostexistsinopsi = false; } } else { doit = "serverdown"; } handler.sendEmptyMessage(0); } }; checkUpdate.start(); } else { new Functions().msgBox(Main.this, getString(R.string.gen_title_error), getString(R.string.at_novalidqr), false); } } else if (requestCode == GET_OPSI_CLIENT_REQUEST && resultCode == Activity.RESULT_OK) { if (data.getStringExtra("message").equals("refresh")) { getOpsiClientsTask(); } // } else if (requestCode == SHOW_OPSI_DEPOT_REQUEST // && resultCode == Activity.RESULT_OK) { // resultconfignames = data.getExtras().getStringArrayList( // "choosenones"); // resultconfigvalues = data.getExtras().getStringArrayList( // "choosenonesvalues"); // event_opsisenddepotconfigchanges(); } }
From source file:mc.inappbilling.v3.InAppBillingHelper.java
int getResponseCodeFromIntent(Intent i) { Object o = i.getExtras().get(RESPONSE_CODE); if (o == null) { logError("Intent with no response code, assuming OK (known issue)"); return BILLING_RESPONSE_RESULT_OK; } else if (o instanceof Integer) return ((Integer) o).intValue(); else if (o instanceof Long) return (int) ((Long) o).longValue(); else {//www .j a v a2 s . co m logError("Unexpected type for intent response code."); logError(o.getClass().getName()); // throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName()); } return -1; }