List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.hybris.mobile.activity.ProfileDetailActivity.java
@SuppressWarnings("unchecked") private void handleIntent(Intent intent) { if (intent.hasExtra("value")) { try {/*from w w w . j av a 2 s. c o m*/ JSONObject profile = new JSONObject(intent.getStringExtra("value")); for (int i = 0; i < entries.size(); i++) { Hashtable<String, Object> dict = (Hashtable<String, Object>) entries.get(i); String path = "$." + dict.get("property").toString(); String value = ""; try { // We append a String a the end to handle the non String objects value = JsonPath.read(profile.toString(), path) + ""; } catch (Exception exp) { value = ""; } dict.put("value", value); } } catch (JSONException e) { LoggingUtils.e(LOG_TAG, "Error parsing json. " + e.getLocalizedMessage(), Hybris.getAppContext()); } } }
From source file:com.google.android.gms.samples.wallet.ConfirmationActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_CHANGE_MASKED_WALLET: if (resultCode == Activity.RESULT_OK && data.hasExtra(WalletConstants.EXTRA_MASKED_WALLET)) { mMaskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET); ((FullWalletConfirmationButtonFragment) getResultTargetFragment()) .updateMaskedWallet(mMaskedWallet); displayLoyaltyInformation(); }/*from w w w. j av a 2 s. c om*/ // you may also want to use the new masked wallet data here, say to recalculate // shipping or taxes if shipping address changed break; case WalletConstants.RESULT_ERROR: int errorCode = data.getIntExtra(WalletConstants.EXTRA_ERROR_CODE, 0); handleError(errorCode); break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:com.pindroid.activity.FragmentBaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (PindroidApplication) getApplicationContext(); mAccountManager = AccountManager.get(this); if (getSupportActionBar() != null) { getSupportActionBar().setHomeButtonEnabled(true); }// ww w .ja v a 2 s .c om Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults")) { if (intent.hasExtra("username")) app.setUsername(intent.getStringExtra("username")); if (intent.hasExtra(SearchManager.QUERY)) { //Intent i = new Intent(this, MainSearchResults.class); //i.putExtras(intent.getExtras()); //startActivity(i); //finish(); } else { onSearchRequested(); } } //init(); }
From source file:com.google.ipc.invalidation.ticl.android.c2dm.C2DMObserver.java
/** * Returns {@code true} if the provided intent matches the selection criteria for this * observer./*from w ww . ja v a2 s.c o m*/ */ boolean matches(Intent intent) { if (selectKey == null) { return true; } if (intent.hasExtra(selectKey)) { return selectValue == null || selectValue.equals(intent.getStringExtra(selectKey)); } return false; }
From source file:com.novoda.imageloader.core.service.CacheCleanerTest.java
private Intent prepareStandardIntent() { Intent i = Mockito.mock(Intent.class); when(i.getAction()).thenReturn(CacheCleaner.CLEAN_CACHE_ACTION); when(i.hasExtra(CacheCleaner.CACHE_DIR_EXTRA)).thenReturn(true); when(i.getStringExtra(CacheCleaner.CACHE_DIR_EXTRA)).thenReturn(cacheDir.getAbsolutePath()); return i;//from www . j a va 2 s . c o m }
From source file:com.doctoror.fuckoffmusicplayer.presentation.playback.PlaybackAndroidService.java
private void onActionSeek(final Intent intent) { if (intent.hasExtra(EXTRA_POSITION_PERCENT)) { onActionSeek(intent.getFloatExtra(EXTRA_POSITION_PERCENT, 0f)); }//from w ww .j a va 2 s . c o m }
From source file:at.ac.uniklu.mobile.sportal.DashboardActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dashboard);/*from w ww . j a va 2s.co m*/ new ActionBarHelper(this).setupHeader().addActionMenu(); mAutomuteButton = (TextView) findViewById(R.id.automute_toggle); mAutomuteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Analytics.onEvent(Analytics.EVENT_AUTOMUTE_TOGGLESWITCH); openSettings(); } }); mServiceBroadcastReceiver = new ServiceToActivityBroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); if (intent.hasExtra(MutingService.ACTION_RESPONSE_ISRUNNING)) { refreshAutomuteButton(intent.getExtras().getBoolean(MutingService.ACTION_RESPONSE_ISRUNNING)); } } }; // register for cloud messaging GCMUtils.OnMainActivityCreate(this); }
From source file:com.flowzr.activity.EntityListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); Intent intent = getIntent(); if (intent.hasExtra(ReportsListFragment.EXTRA_REPORT_TYPE) || intent.hasExtra(REQUEST_REPORTS) || intent.hasExtra(REQUEST_PLANNER)) { setContentView(R.layout.main_reports); } else {// w w w . j av a 2s. c o m setContentView(R.layout.main_entities); } //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, //only way found to remove on various devices 2.3x, 3.0, ... getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212"))); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); //setupDrawer(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (intent.hasExtra(ReportsListFragment.EXTRA_REPORT_TYPE)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.report); Fragment f = new ReportFragment(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(MainActivity.REQUEST_SPLIT_BLOTTER)) { Fragment f = new BudgetBlotterFragment(); f.setArguments(intent.getExtras()); intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.blotter); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_BUDGET_BLOTTER)) { Fragment f = new BudgetBlotterFragment(); f.setArguments(intent.getExtras()); intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.blotter); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_REPORTS)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.reports_list); transaction.replace(R.id.fragment_container, new ReportsListFragment()); } else if (intent.hasExtra(REQUEST_EXCHANGE_RATES)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.reports_list); transaction.replace(R.id.fragment_container, new ExchangeRatesListFragment()); } else if (intent.hasExtra(REQUEST_CATEGORY_SELECTOR)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.category_selector); transaction.replace(R.id.fragment_container, new CategorySelectorFragment()); } else if (intent.hasExtra(REQUEST_SCHEDULED)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.scheduled_transactions); transaction.replace(R.id.fragment_container, new ScheduledListActivity()); } else if (intent.hasExtra(REQUEST_PLANNER)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.planner); if (findViewById(R.id.fragment_land_container) != null) { transaction.replace(R.id.fragment_land_container, new PlannerActivity()); } else { transaction.replace(R.id.fragment_container, new PlannerActivity()); } } else if (intent.hasExtra(REQUEST_MASS_OP)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.blotter_mass_op); transaction.replace(R.id.fragment_container, new MassOpActivity()); } else if (intent.hasExtra(REQUEST_TEMPLATES)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.templates); transaction.replace(R.id.fragment_container, new TemplatesListFragment()); } else if (intent.hasExtra(REQUEST_NEW_TRANSACTION_FROM_TEMPLATE)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.templates); transaction.replace(R.id.fragment_container, new SelectTemplateActivity()); } else if (intent.hasExtra(REQUEST_BLOTTER_TOTALS)) { Fragment f = new BlotterTotalsDetailsFragment(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_ACCOUNT_TOTALS)) { Fragment f = new AccountListTotalsDetailsActivity(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_BUDGET_TOTALS)) { Fragment f = new BudgetListTotalsDetailsActivity(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else { transaction.replace(R.id.fragment_container, new EntityListFragment()); } transaction.commit(); }
From source file:com.flowzr.budget.holo.activity.EntityListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); Intent intent = getIntent(); if (intent.hasExtra(ReportsListFragment.EXTRA_REPORT_TYPE) || intent.hasExtra(REQUEST_REPORTS) || intent.hasExtra(REQUEST_PLANNER)) { setContentView(R.layout.main_reports); } else {// w ww .j a v a2 s . co m setContentView(R.layout.main_entities); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); //setupDrawer(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (intent.hasExtra(ReportsListFragment.EXTRA_REPORT_TYPE)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.report); Fragment f = new ReportFragment(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(MainActivity.REQUEST_SPLIT_BLOTTER)) { Fragment f = new BudgetBlotterFragment(); f.setArguments(intent.getExtras()); intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.blotter); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_BUDGET_BLOTTER)) { Fragment f = new BudgetBlotterFragment(); f.setArguments(intent.getExtras()); intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.blotter); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_REPORTS)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.reports_list); transaction.replace(R.id.fragment_container, new ReportsListFragment()); } else if (intent.hasExtra(REQUEST_EXCHANGE_RATES)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.reports_list); transaction.replace(R.id.fragment_container, new ExchangeRatesListFragment()); } else if (intent.hasExtra(REQUEST_CATEGORY_SELECTOR)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.category_selector); transaction.replace(R.id.fragment_container, new CategorySelectorFragment()); } else if (intent.hasExtra(REQUEST_SCHEDULED)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.scheduled_transactions); transaction.replace(R.id.fragment_container, new ScheduledListActivity()); } else if (intent.hasExtra(REQUEST_PLANNER)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.planner); if (findViewById(R.id.fragment_land_container) != null) { transaction.replace(R.id.fragment_land_container, new PlannerActivity()); } else { transaction.replace(R.id.fragment_container, new PlannerActivity()); } } else if (intent.hasExtra(REQUEST_MASS_OP)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.blotter_mass_op); transaction.replace(R.id.fragment_container, new MassOpActivity()); } else if (intent.hasExtra(REQUEST_TEMPLATES)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.templates); transaction.replace(R.id.fragment_container, new TemplatesListFragment()); } else if (intent.hasExtra(REQUEST_NEW_TRANSACTION_FROM_TEMPLATE)) { intent.putExtra(AbstractTotalListFragment.EXTRA_LAYOUT, R.layout.templates); transaction.replace(R.id.fragment_container, new SelectTemplateActivity()); } else if (intent.hasExtra(REQUEST_BLOTTER_TOTALS)) { Fragment f = new BlotterTotalsDetailsFragment(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_ACCOUNT_TOTALS)) { Fragment f = new AccountListTotalsDetailsActivity(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else if (intent.hasExtra(REQUEST_BUDGET_TOTALS)) { Fragment f = new BudgetListTotalsDetailsActivity(); f.setArguments(intent.getExtras()); transaction.replace(R.id.fragment_container, f); } else { transaction.replace(R.id.fragment_container, new EntityListFragment()); } transaction.commit(); }
From source file:com.android.tripgenie.auto.MessagingService.java
@Override protected void onHandleIntent(Intent intent) { // Handle intent to send a new notification. if (intent != null && SEND_MESSAGE_ACTION.equals(intent.getAction())) { String message = intent.hasExtra("message") ? intent.getStringExtra("message") : Conversations.getUnreadMessage(); Log.d(TAG, "Handling intent for message: " + message); sendNotificationForConversation(Conversations.CONVERSATION_ID, Conversations.SENDER_NAME, message, System.currentTimeMillis()); }/*w w w .j a v a 2s . c o m*/ }