List of usage examples for android.content Intent getIntExtra
public int getIntExtra(String name, int defaultValue)
From source file:net.helff.wificonnector.WifiConnectivityService.java
@Override protected void onHandleIntent(Intent intent) { int cmd = intent.getIntExtra(INTENT_COMMAND, COMMAND_REFRESH_STATUS); // Always send status first for fast gui response sendStatusIntent();/* w w w . java 2 s . c o m*/ switch (cmd) { case COMMAND_SEND_STATUS: case COMMAND_REFRESH_STATUS: case COMMAND_CHECK_CONNECTION: try { // check if network is already unlocked checkConnectivity(false); } catch (ConnectionWorkflowException e) { if (e.getCause() != null) { Log.e("WifiConnectivityService", e.getMessage(), e.getCause()); } else { Log.d("WifiConnectivityService", e.getMessage()); } } break; case COMMAND_AUTO_UNLOCK_CONNECTION: case COMMAND_UNLOCK_CONNECTION: try { // check if network is already unlocked if (checkConnectivity(false)) { break; } // post mobile-number to login page submitMSISDN(httpClient, localContext, mobileNumber); // wait for SMS to arrive and parse token LoginToken loginToken = waitForToken(); // post token to confirmation page submitToken(httpClient, localContext, loginToken); // check connectivity to web page checkInternetAccess(httpClient, localContext, true); } catch (ConnectionWorkflowException e) { if (e.getCause() != null) { Log.e("WifiConnectivityService", e.getMessage(), e.getCause()); } else { Log.d("WifiConnectivityService", e.getMessage()); } } break; case COMMAND_LOCK_CONNECTION: try { checkWifi(); // check connectivity to google or other page logout(httpClient); } catch (ConnectionWorkflowException e) { if (e.getCause() != null) { Log.e("WifiConnectivityService", e.getMessage(), e.getCause()); } else { Log.d("WifiConnectivityService", e.getMessage()); } } break; } }
From source file:com.flat20.fingerplay.FingerPlayActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_PURCHASE) { if (resultCode == RESULT_OK && data.getIntExtra("RESPONSE_CODE", 1) == 0) { checkPurchases();//from w ww. jav a 2s . c o m } else { unableToVerifyLicense(getString(R.string.billing_error_during_process), true); } } }
From source file:alaindc.crowdroid.SendIntentService.java
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); // DIFFERENTIATE like in sensorIntentService per each sensor! if (action.startsWith(Constants.ACTION_SENDDATA)) { handleActionSendData(intent.getIntExtra(Constants.EXTRA_TYPE_OF_SENSOR_TO_SEND, -1)); // Name in shared preference } else if (action.startsWith(Constants.ACTION_RECEIVEDDATA)) { final String response = intent.getStringExtra(Constants.EXTRA_SENSE_RESPONSE); handleActionReceivedData(response); } else if (action.startsWith(Constants.ACTION_GETSUBSCRIPTION)) { handleActionGetSubscriptions(); } else if (action.startsWith(Constants.ACTION_UPDATESUBSCRIPTION)) { handleActionUpdateSubscriptions(intent.getStringExtra(Constants.EXTRA_BODY_UPDATESUBSCRIPTION)); } else if (action.startsWith(Constants.ACTION_RECEIVEDSUBSCRIPTION)) { handleActionReceivedSubscriptions(intent.getStringExtra(Constants.EXTRA_SUBSCRIPTION_RESPONSE)); } else if (action.startsWith(Constants.ACTION_RECEIVEDTHROUGHPUT)) { handleActionReceivedThroughput(intent.getLongExtra(Constants.EXTRA_THROUGHPUT_RESPONSE, -1)); }// w ww . ja v a 2 s.c o m } }
From source file:me.henrytao.bootstrapandroidlibrarydemo.activity.BaseActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1001) { int responseCode = data.getIntExtra("RESPONSE_CODE", 0); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (resultCode == RESULT_OK) { new AlertDialog.Builder(BaseActivity.this).setMessage(getString(R.string.text_donate_thanks)) .setPositiveButton(R.string.text_close, null).show(); } else {//from w w w . j a va2 s.c o m showDonateDialogErrorCallback(null); } } }
From source file:com.dictionary.activity.ArticleCollectionActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Application app = (Application) getApplication(); app.installTheme(this); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.activity_article_collection_loading); app.push(this); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setSubtitle("..."); final Intent intent = getIntent(); final int position = intent.getIntExtra("position", 0); AsyncTask<Void, Void, ArticleCollectionPagerAdapter> createAdapterTask = new AsyncTask<Void, Void, ArticleCollectionPagerAdapter>() { @Override//from ww w . ja v a2s . com protected ArticleCollectionPagerAdapter doInBackground(Void... params) { ArticleCollectionPagerAdapter result; Uri articleUrl = intent.getData(); if (articleUrl != null) { result = createFromUri(app, articleUrl); } else { String action = intent.getAction(); if (action == null) { result = createFromLastResult(app); } else if (action.equals("showRandom")) { result = createFromRandom(app); } else if (action.equals("showBookmarks")) { result = createFromBookmarks(app); } else if (action.equals("showHistory")) { result = createFromHistory(app); } else { result = createFromIntent(app, intent); } } return result; } @Override protected void onPostExecute(ArticleCollectionPagerAdapter adapter) { if (isFinishing() || onDestroyCalled) { return; } articleCollectionPagerAdapter = adapter; if (articleCollectionPagerAdapter == null || articleCollectionPagerAdapter.getCount() == 0) { int messageId; if (articleCollectionPagerAdapter == null) { messageId = R.string.article_collection_invalid_link; } else { messageId = R.string.article_collection_nothing_found; } Toast.makeText(ArticleCollectionActivity.this, messageId, Toast.LENGTH_SHORT).show(); finish(); return; } if (position > articleCollectionPagerAdapter.getCount() - 1) { Toast.makeText(ArticleCollectionActivity.this, R.string.article_collection_selected_not_available, Toast.LENGTH_SHORT).show(); finish(); return; } setContentView(R.layout.activity_article_collection); findViewById(R.id.pager_title_strip).setVisibility( articleCollectionPagerAdapter.getCount() == 1 ? ViewGroup.GONE : ViewGroup.VISIBLE); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(articleCollectionPagerAdapter); viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(final int position) { updateTitle(position); runOnUiThread(new Runnable() { @Override public void run() { ArticleFragment fragment = (ArticleFragment) articleCollectionPagerAdapter .getItem(position); fragment.applyTextZoomPref(); } }); } }); viewPager.setCurrentItem(position); PagerTitleStrip titleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip); titleStrip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10); updateTitle(position); articleCollectionPagerAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { if (articleCollectionPagerAdapter.getCount() == 0) { finish(); } } }); } }; createAdapterTask.execute(); }
From source file:org.openplans.rcavl.LocationService.java
public void realStart(Intent intent) { String url = intent.getStringExtra("pingUrl"); String email = intent.getStringExtra("email"); String password = intent.getStringExtra("password"); pingInterval = intent.getIntExtra("pingInterval", 60); Notification notification = new Notification(R.drawable.icon, "Ridepilot Mobile", System.currentTimeMillis()); Intent appIntent = new Intent(this, RCAVL.class); appIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, appIntent, 0); notification.setLatestEventInfo(this, "Ridepilot Mobile", "connected", pi); notification.flags |= Notification.FLAG_NO_CLEAR; startForeground(66786, notification); thread = new LocationServiceThread(url, email, password); new Thread(thread).start(); }
From source file:app.com.vaipo.ContactsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == Activity.RESULT_OK) { int action = data.getIntExtra("action", InCallActivityDialog.ACTION_NONE); int option = data.getIntExtra("option", InCallActivityDialog.OPTION_NONE); switch (action) { case InCallActivityDialog.ACTION_END: Utils.endVaipoCall(getActivity()); break; case InCallActivityDialog.ACTION_MUTE: break; case InCallActivityDialog.ACTION_SPKR: break; case InCallActivityDialog.ACTION_SWAP: break; }/*from w ww. j av a 2s. c o m*/ } if (resultCode == Activity.RESULT_CANCELED) { //Write your code if there's no result } } }
From source file:com.auth0.lock.passwordless.LockPasswordlessActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.com_auth0_passwordless_activity_lock_passwordless); passwordlessType = MODE_UNKNOWN; lock = getLock();//from w w w .ja va2 s . com client = lock.getAuthenticationAPIClient(); bus = lock.getBus(); if (savedInstanceState == null) { isInProgress = false; Intent intent = getIntent(); boolean invalidMagicLink = false; int mode = intent.getIntExtra(PASSWORDLESS_TYPE_PARAMETER, MODE_UNKNOWN); if (mode != MODE_UNKNOWN) { setPasswordlessType(mode); } else { AppLinkIntentParser linkParser = new AppLinkIntentParser(intent); invalidMagicLink = linkParser.isAppLinkIntent(); if (invalidMagicLink) { setPasswordlessType(linkParser.getModeFromAppLink()); } } if (passwordlessType == MODE_UNKNOWN) { Log.e(TAG, "Passwordless type is unknown, the intent that started the activity is " + intent); finish(); } Fragment initialFragment = isEmailType() ? RequestCodeEmailFragment.newInstance(useMagicLink()) : RequestCodeSmsFragment.newInstance(useMagicLink()); getSupportFragmentManager().beginTransaction().add(R.id.com_auth0_container, initialFragment).commit(); if (invalidMagicLink) { Fragment fragment = new InvalidLinkFragment(); getSupportFragmentManager().beginTransaction().replace(R.id.com_auth0_container, fragment) .addToBackStack(fragment.getClass().getName()).commit(); } } else { setPasswordlessType(savedInstanceState.getInt(PASSWORDLESS_TYPE_PARAMETER)); isInProgress = savedInstanceState.getBoolean(IS_IN_PROGRESS_PARAMETER); username = savedInstanceState.getString(USERNAME_PARAMETER); } errorBuilder = new LoginAuthenticationErrorBuilder(R.string.com_auth0_passwordless_login_error_title, R.string.com_auth0_passwordless_login_error_message, isEmailType() ? R.string.com_auth0_passwordless_login_invalid_credentials_message_email : R.string.com_auth0_passwordless_login_invalid_credentials_message_sms, R.string.com_auth0_db_login_unauthorized_error_message); ActivityUIHelper.configureScreenModeForActivity(this, lock); }
From source file:com.josephblough.sbt.activities.ShortcutActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // If criteria has been selected then load the details data if (resultCode == RESULT_OK && data != null && data.hasExtra(SEARCH_TYPE)) { final int searchType = data.getIntExtra(SEARCH_TYPE, 0); final String criteria = data.getStringExtra(CRITERIA); createLauncher(searchType, criteria); } else {//ww w. j ava 2s.co m setResult(RESULT_CANCELED, new Intent()); finish(); } }
From source file:me.henrytao.smoothappbarlayoutdemo.activity.BaseActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1001) { int responseCode = data.getIntExtra("RESPONSE_CODE", 0); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (resultCode == RESULT_OK) { new AlertDialog.Builder(BaseActivity.this).setMessage(getString(R.string.text_thanks_for_donate)) .setPositiveButton(R.string.close, null).show(); } else {/* w ww . j a v a 2s. co m*/ showDonateDialogErrorCallback(null); } } }