List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.granita.tasks.notification.NotificationActionIntentService.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) @Override/*from ww w. j av a 2s. c o m*/ protected void onHandleIntent(Intent intent) { mAuthority = getString(R.string.org_dmfs_tasks_authority); final String action = intent.getAction(); final Context context = this; if (intent.hasExtra(EXTRA_NOTIFICATION_ID)) { Uri taskUri = intent.getData(); int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.cancel(notificationId); if (ACTION_COMPLETE.equals(action)) { markCompleted(taskUri); } else if (intent.hasExtra(EXTRA_TASK_DUE) && intent.hasExtra(EXTRA_TIMEZONE)) { long due = intent.getLongExtra(EXTRA_TASK_DUE, -1); String tz = intent.getStringExtra(EXTRA_TIMEZONE); boolean allDay = intent.getBooleanExtra(EXTRA_ALLDAY, false); if (ACTION_DELAY_1H.equals(action)) { Time time = new Time(tz); time.set(due); time.allDay = false; time.hour++; time.normalize(true); delayTask(taskUri, time); } else if (ACTION_DELAY_1D.equals(action)) { if (tz == null) { tz = "UTC"; } Time time = new Time(tz); time.set(due); time.allDay = allDay; time.monthDay++; time.normalize(true); delayTask(taskUri, time); } } } else if (intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) { /* * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent to add some extra data, it must unparcel the * NotificationAction object. It throws a ClassNotFoundException when unparcelling. To avoid this, do the marshalling ourselves. */ final NotificationAction notificationAction; final byte[] data = intent.getByteArrayExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION); if (data != null) { final Parcel in = Parcel.obtain(); in.unmarshall(data, 0, data.length); in.setDataPosition(0); notificationAction = NotificationAction.CREATOR.createFromParcel(in, NotificationAction.class.getClassLoader()); } else { return; } if (NotificationActionUtils.ACTION_UNDO.equals(action)) { NotificationActionUtils.cancelUndoTimeout(context, notificationAction); NotificationActionUtils.cancelUndoNotification(context, notificationAction); resendNotification(notificationAction); } else if (ACTION_COMPLETE.equals(action)) { // All we need to do is switch to an Undo notification NotificationActionUtils.createUndoNotification(context, notificationAction); NotificationActionUtils.registerUndoTimeout(this, notificationAction); } else { if (NotificationActionUtils.ACTION_UNDO_TIMEOUT.equals(action) || NotificationActionUtils.ACTION_DESTRUCT.equals(action)) { // Process the action NotificationActionUtils.cancelUndoTimeout(this, notificationAction); NotificationActionUtils.processUndoNotification(this, notificationAction); processDesctructiveNotification(notificationAction); } } } }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningActivity.java
/** * Get markt naam from the shared prefs, set the title and subtitle, and instantiate the * dagvergunning fragment// www .j a v a2s.co m * @param savedInstanceState the saved activity state */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set the title in the toolbar Intent intent = getIntent(); if ((intent != null) && (intent.hasExtra( MakkelijkeMarktProvider.mTableDagvergunning + MakkelijkeMarktProvider.Dagvergunning.COL_ID))) { setToolbarTitle(getString(R.string.dagvergunning_edit)); } else { setToolbarTitle(getString(R.string.dagvergunning_add)); } // get selected markt naam from sharedpreferences and set the subtitle in the toolbar SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); String marktNaam = settings.getString(getString(R.string.sharedpreferences_key_markt_naam), ""); setToolbarSubtitle(marktNaam); // create new or get existing instance of dagvergunningfragment if (savedInstanceState == null) { mDagvergunningFragment = new DagvergunningFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.container, mDagvergunningFragment, DAGVERGUNNING_FRAGMENT_TAG); transaction.commit(); } else { mDagvergunningFragment = (DagvergunningFragment) getSupportFragmentManager() .findFragmentByTag(DAGVERGUNNING_FRAGMENT_TAG); } // set the active drawer menu option if (mDrawerFragment.isAdded()) { mDrawerFragment.checkItem(mDrawerFragment.DRAWER_POSITION_DAGVERGUNNINGEN); } // replace the drawer hamburger with the back-arrow if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(false); mDrawerToggle.setDrawerIndicatorEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } // connect to the google api client to get the location if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); } // create a location request mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(LOCATION_UPDATES_INTERVAL); mLocationRequest.setFastestInterval(FASTEST_LOCATION_UPDATES_INTERVAL); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // check if we have location request permissions checkLocationPermissions(); }
From source file:com.example.android.cloudnotes.ui.HomeActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case CHOOSE_ACCOUNT: if (resultCode == RESULT_OK && data != null && data.hasExtra(AccountManager.KEY_ACCOUNT_NAME)) { final String syncAccount = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); if (!TextUtils.isEmpty(syncAccount)) { SharedPreferences.Editor prefs = getSharedPreferences(KEY_PREFS, MODE_PRIVATE).edit(); prefs.putString(AccountManager.KEY_ACCOUNT_NAME, syncAccount); prefs.commit();/*from ww w. j a v a 2 s . c om*/ // resume syncing startDriveSync(); } } break; case AUTH_APP: if (resultCode == RESULT_OK) { // resume syncing startDriveSync(); } break; default: break; } }
From source file:com.fbartnitzek.tasteemall.filter.EntityFilterTabFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.v(LOG_TAG, "onActivityResult, hashCode=" + this.hashCode() + ", " + "requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]"); if (requestCode == REQUEST_ATTRIBUTE_FILTER_CODE && resultCode == Activity.RESULT_OK) { if (data.hasExtra(EXTRA_ATTRIBUTE_FILTERED)) { RecyclerView.ViewHolder vh = mAttributesRecycler.findViewHolderForAdapterPosition(mPosition); Log.v(LOG_TAG, "onActivityResult, hashCode=" + this.hashCode() + ", " + "vh=" + vh); // snackbar with all filters for entity...? - not usable for selection... // TODO: store to restore, maybe via jsonFilter... if (data.getBooleanExtra(EXTRA_ATTRIBUTE_FILTERED, false)) { mSelected.add(mPosition); vh.itemView.setBackgroundColor(Color.GREEN); } else { mSelected.remove((Integer) mPosition); vh.itemView.setBackgroundColor(Color.TRANSPARENT); }// w ww.java2 s . c o m } } super.onActivityResult(requestCode, resultCode, data); }
From source file:net.openwatch.acluaz.FormFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs_pager); // Show the Up button in the action bar. this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); getDisplayWidth();/* w w w. j a va2 s.c o m*/ mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.personal_tab)).setIndicator( inflateCustomTab(getString(R.string.personal_tab))), PersonalFormFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.incident_tab)).setIndicator( inflateCustomTab(getString(R.string.incident_tab))), IncidentFormFragment.class, null); /* mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.personal_tab)).setIndicator(inflateCustomTab(getString(R.string.personal_tab))), PersonalFormFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.event_tab)).setIndicator(inflateCustomTab(getString(R.string.event_tab))), RemoteFeedFragmentActivity.RemoteRecordingsListFragment.class, null); */ if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } DeviceLocation location = new DeviceLocation(); location.getLocation(getApplicationContext(), new LocationResult() { @Override public void gotLocation(Location location) { if (FormFragmentActivity.this != null && FormFragmentActivity.this.findViewById(R.id.gps_toggle) != null) { FormFragmentActivity.this.findViewById(R.id.gps_toggle).setTag(R.id.view_tag, location); //Log.i(TAG, "Tagged location_input with : " + FormFragmentActivity.this.findViewById(R.id.gps_toggle).getTag(R.id.view_tag).toString()); } } }, true); Intent i = getIntent(); if (!i.hasExtra(Constants.INTERNAL_DB_ID)) { AlertDialog.Builder builder = new AlertDialog.Builder(FormFragmentActivity.this); builder.setMessage(getString(R.string.pre_form_disclaimer)) .setPositiveButton(getString(R.string.dialog_ok), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); } }
From source file:com.duy.pascal.interperter.libraries.android.connection.bluetooth.AndroidBluetoothLib.java
@SuppressWarnings("unused") @PascalMethod(description = "Connect to a device over Bluetooth. Blocks until the connection is established or fails.", returns = "True if the connection was established successfully.") public String bluetoothConnect( @PascalParameter(name = "uuid", description = "The UUID passed here must match the UUID used by the server device.") @RpcDefault(DEFAULT_UUID) String uuid, @PascalParameter(name = "address", description = "The user will be presented with a list of discovered devices to choose from if an address is not provided.") @RpcOptional String address) throws IOException { if (address == null) { Intent deviceChooserIntent = new Intent(); deviceChooserIntent.setComponent(Constants.BLUETOOTH_DEVICE_LIST_COMPONENT_NAME); Intent result = mAndroidFacade.startActivityForResult(deviceChooserIntent); if (result != null && result.hasExtra(Constants.EXTRA_DEVICE_ADDRESS)) { address = result.getStringExtra(Constants.EXTRA_DEVICE_ADDRESS); } else {//from w w w.j av a 2 s. co m return null; } } BluetoothDevice mDevice; BluetoothSocket mSocket; BluetoothConnection conn; mDevice = mBluetoothAdapter.getRemoteDevice(address); mSocket = mDevice.createRfcommSocketToServiceRecord(UUID.fromString(uuid)); // Always cancel discovery because it will slow down a connection. mBluetoothAdapter.cancelDiscovery(); mSocket.connect(); conn = new BluetoothConnection(mSocket); return addConnection(conn); }
From source file:com.eugene.fithealthmaingit.MainActivity.java
/** * Get the Results from the Other Activities * * @param requestCode In this case either 1 = ACTIVITY_ONE_REQUEST or 2 = ACTIVITY_TWO_REQUEST * @param resultCode Determines whether the request was successful. * @param data The being sent from other activities via Intent *//*from w ww. j a va 2s . c om*/ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ACTIVITY_ONE_REQUEST && resultCode == RESULT_OK) { if (data.hasExtra(ACTIVITY_ONE_RESULT)) { Date result = (Date) data.getExtras().get(ACTIVITY_ONE_RESULT); Fragment fragmentJournalMainHome = new FragmentJournalMainHome(); Bundle bundle = new Bundle(); bundle.putSerializable("DATE", result); fragmentJournalMainHome.setArguments(bundle); if (fragmentJournalMainHome != null && result != new Date()) getSupportFragmentManager().beginTransaction() .replace(R.id.container, fragmentJournalMainHome, "JOURNAL").commitAllowingStateLoss(); } } }
From source file:com.irccloud.android.RemoteInputService.java
@Override protected void onHandleIntent(Intent intent) { boolean success = false; String sk = getSharedPreferences("prefs", 0).getString("session_key", ""); if (intent != null && sk != null && sk.length() > 0) { final String action = intent.getAction(); if (ACTION_REPLY.equals(action)) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null || intent.hasExtra("reply")) { Crashlytics.log(Log.INFO, "IRCCloud", "Got reply from RemoteInput"); String reply = remoteInput != null ? remoteInput.getCharSequence("extra_reply").toString() : intent.getStringExtra("reply"); if (reply.length() > 0 && !reply.contains("\n/") && (!reply.startsWith("/") || reply.toLowerCase().startsWith("/me ") || reply.toLowerCase().startsWith("/slap "))) { try { JSONObject o = NetworkConnection.getInstance().say(intent.getIntExtra("cid", -1), intent.getStringExtra("to"), reply, sk); success = o.getBoolean("success"); } catch (Exception e) { e.printStackTrace(); }// w w w.ja v a2 s. c o m } NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext()) .cancel(intent.getIntExtra("bid", 0)); if (intent.hasExtra("eids")) { int bid = intent.getIntExtra("bid", -1); long[] eids = intent.getLongArrayExtra("eids"); for (int j = 0; j < eids.length; j++) { if (eids[j] > 0) { Notifications.getInstance().dismiss(bid, eids[j]); } } } if (!success) Notifications.getInstance().alert(intent.getIntExtra("bid", -1), "Sending Failed", reply.startsWith("/") ? "Please launch the IRCCloud app to send this command" : "Your message was not sent. Please try again shortly."); } else { Crashlytics.log(Log.ERROR, "IRCCloud", "RemoteInputService received no remoteinput"); } } } }
From source file:com.yeldi.yeldibazaar.FDroid.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_APPDETAILS: break;/*from ww w . j a va2 s.c o m*/ case REQUEST_MANAGEREPOS: if (data.hasExtra("update")) { AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this); ask_alrt.setTitle(getString(R.string.repo_update_title)); ask_alrt.setIcon(android.R.drawable.ic_menu_rotate); ask_alrt.setMessage(getString(R.string.repo_alrt)); ask_alrt.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { updateRepos(); } }); ask_alrt.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); AlertDialog alert = ask_alrt.create(); alert.show(); } break; case REQUEST_PREFS: // The automatic update settings may have changed, so reschedule // (or // unschedule) the service accordingly. It's cheap, so no need // to // check if the particular setting has actually been changed. UpdateService.schedule(getBaseContext()); if (data != null && data.hasExtra("update")) { updateRepos(); } else if (data != null && data.hasExtra("restart")) { final Intent intent = getIntent(); overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); finish(); overridePendingTransition(0, 0); startActivity(intent); } else { repopulateViews(); } break; } }
From source file:com.example.evan.comp296.profile.MainActivity_Profile.java
@Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); // Check if this Activity was launched by clicking on an upload notification if (intent.hasExtra(MyUploadService.EXTRA_DOWNLOAD_URL)) { try {//from w w w . ja v a 2 s . c o m onUploadResultIntent(intent); } catch (IOException e) { e.printStackTrace(); } } }