List of usage examples for android.content Intent getIntExtra
public int getIntExtra(String name, int defaultValue)
From source file:com.cyanogenmod.eleven.ui.activities.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // if we've been launched by an intent, parse it Intent launchIntent = getIntent(); boolean intentHandled = false; if (launchIntent != null) { intentHandled = parseIntentForFragment(launchIntent); }//from w w w. j a v a 2 s . com // if the intent didn't cause us to load a fragment, load the music browse one if (savedInstanceState == null && !mLoadedBaseFragment) { final MusicBrowserPhoneFragment fragment = new MusicBrowserPhoneFragment(); if (launchIntent != null) { fragment.setDefaultPageIdx(launchIntent.getIntExtra(EXTRA_BROWSE_PAGE_IDX, MusicBrowserPhoneFragment.INVALID_PAGE_INDEX)); } getSupportFragmentManager().beginTransaction().replace(R.id.activity_base_content, fragment).commit(); mLoadedBaseFragment = true; mTopLevelActivity = true; } getSupportFragmentManager().addOnBackStackChangedListener(this); // if we are resuming from a saved instance state if (savedInstanceState != null) { // track which fragments are loaded and if this is the top level activity mTopLevelActivity = savedInstanceState.getBoolean(STATE_KEY_BASE_FRAGMENT); mLoadedBaseFragment = mTopLevelActivity; // update the action bar based on the top most fragment onBackStackChanged(); // figure which panel we are on and update the status bar mBrowsePanelActive = (getCurrentPanel() == Panel.Browse); updateStatusBarColor(); } // if intent wasn't UI related, process it as a audio playback request if (!intentHandled) { handlePlaybackIntent(launchIntent); } }
From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (pendingPurchaseCallbacks.containsKey(requestCode)) { jsLog("Got response of a purchase"); // going to handle response of a purchase CallbackContext callbackContext = pendingPurchaseCallbacks.get(requestCode); int responseCode = data.getIntExtra("RESPONSE_CODE", 0); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) { if (purchaseData == null || dataSignature == null) { callbackContext//w w w . j a va 2 s .c o m .error(new Error(ERR_PURCHASE_FAILED, "Empty purchase data or empty signature returned") .toJavaScriptJSON()); } else { try { Purchase purchase = new Purchase(purchaseData, dataSignature); if (base64EncodedPublicKey != null && !Security.verifyPurchase(base64EncodedPublicKey, purchaseData, dataSignature)) { callbackContext.error(new Error(ERR_PAYMENT_INVALID, "Signature verification failed") .toJavaScriptJSON()); } else { jsLog("Purchase successful."); // add the purchase to the inventory myInventory.addPurchase(purchase); callbackContext.success(purchase.toJavaScriptJson()); } } catch (JSONException e) { callbackContext .error(new Error(ERR_JSON_CONVERSION_FAILED, e.getMessage()).toJavaScriptJSON()); } } } else if (resultCode == Activity.RESULT_CANCELED) { callbackContext .error(new Error(ERR_PAYMENT_CANCELLED, "Purchase cancelled by user.").toJavaScriptJSON()); } else { // unknown result, interpret as error callbackContext .error(new Error(ERR_PURCHASE_FAILED, "Unknown result code from activity. ResultCode: " + resultCode + " ResponseCode: " + responseCode).toJavaScriptJSON()); } } }
From source file:app.umitems.greenclock.DeskClock.java
@Override public void onNewIntent(Intent newIntent) { super.onNewIntent(newIntent); if (DEBUG)/*from www .j av a 2s . c o m*/ Log.d(LOG_TAG, "onNewIntent with intent: " + newIntent); // update our intent so that we can consult it to determine whether or // not the most recent launch was via a dock event setIntent(newIntent); // Timer receiver may ask to go to the timers fragment if a timer expired. int tab = newIntent.getIntExtra(SELECT_TAB_INTENT_EXTRA, -1); if (tab != -1) { if (mActionBar != null) { mActionBar.setSelectedNavigationItem(tab); } } }
From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java
/** * If the given intent has type data, set a limiter built from that * data.//from ww w . j a v a 2 s .co m */ private void loadLimiterIntent(Intent intent) { Limiter limiter = null; int type = intent.getIntExtra("type", -1); long id = intent.getLongExtra("id", -1); String folder = intent.getStringExtra("folder"); if (type == MediaUtils.TYPE_FILE && folder != null) { limiter = FileSystemAdapter.buildLimiter(new File(folder)); } else if (type != -1 && id != -1) { MediaAdapter adapter = new MediaAdapter(this, type, null, null); adapter.commitQuery(adapter.query()); limiter = adapter.buildLimiter(id); } if (limiter != null) { int tab = mPagerAdapter.setLimiter(limiter); if (tab == -1 || tab == mViewPager.getCurrentItem()) updateLimiterViews(); else mViewPager.setCurrentItem(tab); } }
From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java
/** * "Expand" the view represented by the given intent by setting the limiter * from the view and switching to the appropriate tab. * * @param intent An intent created with/*from w w w . j a v a2s . c om*/ * {@link LibraryAdapter#createData(View)}. */ private void expand(Intent intent) { mBottomBarControls.showSearch(false); int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID); long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID); int tab = mPagerAdapter.setLimiter(mPagerAdapter.mAdapters[type].buildLimiter(id)); if (tab == -1 || tab == mViewPager.getCurrentItem()) updateLimiterViews(); else mViewPager.setCurrentItem(tab); }
From source file:io.clh.lrt.androidservice.TraceListenerService.java
private void traceEvent(Context context, Intent intent) { JSONObject jsonData = new JSONObject(); try {/*from w ww . j a v a2 s.com*/ String appName = intent.getStringExtra("appName"); if (appLut.get(appName) == null) { intent.putExtra("appVersion", "UNKNOWN"); traceEventStart(context, intent); return; } jsonData.put("methodSig", intent.getStringExtra("methodSig")); jsonData.put("timestamp", intent.getStringExtra("timestamp")); jsonData.put("fileName", intent.getStringExtra("fileName")); jsonData.put("lineNumber", intent.getIntExtra("lineNumber", -1)); jsonData.put("seq", intent.getIntExtra("seq", -1)); JSONArray jsonArray = new JSONArray(); jsonArray.put(jsonData); Log.d(TAG, "trace event: " + jsonData.toString()); HttpResponse response = postAPI("traces/" + appLut.get(appName) + "/tracepoints", "trace", jsonArray.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.perm.DoomPlay.PlayingService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { String action = intent.getAction(); assert action != null; if (action.equals(actionOffline) || action.equals(actionOnline)) { isOnline = action.equals(actionOnline); audios = intent.getParcelableArrayListExtra(FullPlaybackActivity.keyService); if (intent.getIntExtra(FullPlaybackActivity.keyIndex, 0) != valueIncredible) indexCurrentTrack = intent.getIntExtra(FullPlaybackActivity.keyIndex, 0); loadMusic();// w w w . java 2 s . c o m } else handleNotifControll(action); return START_NOT_STICKY; }
From source file:com.p2p.misc.DeviceUtility.java
public float batteryLevel() { try {/* w ww . j av a2 s .com*/ BroadcastReceiver batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // context.unregisterReceiver(this); Intent batteryIntent = mactivity.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int rawlevel = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); if (level == -1 || scale == -1) { level = 50.0f; } if (rawlevel >= 0 && scale > 0) { level = ((float) level / (float) scale) * 100.0f; } set_BatteryLevel(level); // Constants.BATTERY_LEVEL=level; System.out.println("Battery Level Remaining: " + level + "%"); } }; IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); mactivity.registerReceiver(batteryReceiver, filter); } catch (Exception e) { e.printStackTrace(); } return level; }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java
/** * Catch the selected koopman of vervanger from dialogactivity result * @param requestCode/*from w w w . j ava2 s. c om*/ * @param resultCode * @param data */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // check for the vervanger dialog request code if (requestCode == VERVANGER_DIALOG_REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { // get the id of the selected koopman from the intent int koopmanId = data.getIntExtra(VERVANGER_RETURN_INTENT_EXTRA_KOOPMAN_ID, 0); if (koopmanId != 0) { // set the koopman that was selected in the dialog mKoopmanId = koopmanId; // reset the default amount of products before loading the koopman String[] productParams = getResources().getStringArray(R.array.array_product_param); for (String product : productParams) { mProducten.put(product, -1); } // update aanwezig status to vervanger_met_toestemming mAanwezigSelectedValue = getString(R.string.item_vervanger_met_toestemming_aanwezig); setAanwezig(getString(R.string.item_vervanger_met_toestemming_aanwezig)); // inform the dagvergunningfragment that the koopman has changed, get the new values, // and populate our layout with the new koopman ((Callback) getActivity()).onKoopmanFragmentUpdated(); } } else if (resultCode == Activity.RESULT_CANCELED) { // clear the selection by restarting the activity Intent intent = getActivity().getIntent(); getActivity().finish(); startActivity(intent); } } }
From source file:com.csounds.examples.tests.SynthActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); System.out.println(" RrequestC resultcode data " + requestCode + " " + resultCode + " " + data); if (requestCode == 0 && resultCode == RESULT_OK && data != null) { System.out.println("datagetIntExtrapresetNbr " + data.getIntExtra("presetNbr", 0)); int presetNbr = data.getIntExtra("presetNbr", 0); this.setPreset(presetNbr); this.presetNbr = presetNbr; }/*from w w w. j a va 2 s.co m*/ }