List of usage examples for android.content Intent getIntExtra
public int getIntExtra(String name, int defaultValue)
From source file:com.dwdesign.tweetings.fragment.AccountsFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUEST_SET_COLOR: { if (resultCode == Activity.RESULT_OK) if (data != null && data.getExtras() != null) { final int color = data.getIntExtra(Accounts.USER_COLOR, Color.WHITE); final ContentValues values = new ContentValues(); values.put(Accounts.USER_COLOR, color); final String where = Accounts.USER_ID + " = " + mSelectedUserId; mResolver.update(Accounts.CONTENT_URI, values, where, null); getLoaderManager().restartLoader(0, null, this); }//from w w w .j a va2 s . c o m break; } } super.onActivityResult(requestCode, resultCode, data); }
From source file:bupt.tiantian.callrecorder.callrecorder.MainActivity.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (null != intent) { // User clicked the {@link RecordCallService#displayNotification} to listen to the recording long id = intent.getIntExtra("RecordingId", -1); if (-1 != id) { CallLog call = Database.getInstance(this).getCall((int) id); if (null != call) { audioPlayer(call.getPathToRecording()); }//ww w.j ava 2 s. co m intent.putExtra("RecordingId", -1); // run only once... } } }
From source file:com.ichi2.anki.Feedback.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); Resources res = getResources(); Context context = getBaseContext(); SharedPreferences sharedPreferences = AnkiDroidApp.getSharedPrefs(context); mReportErrorMode = sharedPreferences.getString("reportErrorMode", REPORT_ASK); mNonce = UUID.randomUUID().getMostSignificantBits(); mFeedbackUrl = res.getString(R.string.feedback_post_url); mErrorUrl = res.getString(R.string.error_post_url); mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mPostingFeedback = false;/*from w ww . java2 s.c om*/ initAllAlertDialogs(); getErrorFiles(); Intent i = getIntent(); mAllowFeedback = (i.hasExtra("request") && (i.getIntExtra("request", 0) == DeckPicker.REPORT_FEEDBACK || i.getIntExtra("request", 0) == DeckPicker.RESULT_DB_ERROR)) || mReportErrorMode.equals(REPORT_ASK); if (!mAllowFeedback) { if (mReportErrorMode.equals(REPORT_ALWAYS)) { // Always report try { String feedback = "Automatically sent"; Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), true })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } } catch (Exception e) { Log.e(AnkiDroidApp.TAG, e.toString()); } finish(); ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); return; } else if (mReportErrorMode.equals(REPORT_NEVER)) { // Never report deleteFiles(false, false); finish(); ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); return; } } View mainView = getLayoutInflater().inflate(R.layout.feedback, null); setContentView(mainView); Themes.setWallpaper(mainView); Themes.setTextViewStyle(findViewById(R.id.tvFeedbackDisclaimer)); Themes.setTextViewStyle(findViewById(R.id.lvFeedbackErrorList)); Button btnSend = (Button) findViewById(R.id.btnFeedbackSend); Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest); Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll); mEtFeedbackText = (EditText) findViewById(R.id.etFeedbackText); mLvErrorList = (ListView) findViewById(R.id.lvFeedbackErrorList); mErrorAdapter = new SimpleAdapter(this, mErrorReports, R.layout.error_item, new String[] { "name", "state", "result" }, new int[] { R.id.error_item_text, R.id.error_item_progress, R.id.error_item_status }); mErrorAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { switch (view.getId()) { case R.id.error_item_progress: if (text.equals(STATE_UPLOADING)) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } return true; case R.id.error_item_status: if (text.length() == 0) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } return false; } }); btnClearAll.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, false); refreshErrorListView(); refreshInterface(); } }); mLvErrorList.setAdapter(mErrorAdapter); btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mPostingFeedback) { String feedback = mEtFeedbackText.getText().toString(); Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), false })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } refreshInterface(); } } }); btnKeepLatest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, true); refreshErrorListView(); refreshInterface(); } }); refreshInterface(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); }
From source file:com.achep.base.ui.activities.SettingsActivity.java
@Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); // Should happen before any call to getIntent() getMetaData();// w w w .j av a 2 s .c om final Intent intent = getIntent(); if (intent.hasExtra(EXTRA_UI_OPTIONS)) { getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); } // Getting Intent properties can only be done after the super.onCreate(...) final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false); final ComponentName cn = intent.getComponent(); final String className = cn.getClassName(); boolean isShowingDashboard = className.equals(Settings2.class.getName()); // This is a "Sub Settings" when: // - this is a real SubSettings // - or :settings:show_fragment_as_subsetting is passed to the Intent final boolean isSubSettings = className.equals(SubSettings.class.getName()) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false); // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets if (isSubSettings) { // Check also that we are not a Theme Dialog as we don't want to override them /* final int themeResId = getTheme(). getThemeResId(); if (themeResId != R.style.Theme_DialogWhenLarge && themeResId != R.style.Theme_SubSettingsDialogWhenLarge) { setTheme(R.style.Theme_SubSettings); } */ } setContentView(R.layout.settings_main_dashboard); mContent = (ViewGroup) findViewById(android.R.id.content); getSupportFragmentManager().addOnBackStackChangedListener(this); if (savedState != null) { // We are restarting from a previous saved state; used that to initialize, instead // of starting fresh. setTitleFromIntent(intent); ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES); if (categories != null) { mCategories.clear(); mCategories.addAll(categories); setTitleFromBackStack(); } mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP); } else { if (!isShowingDashboard) { mDisplayHomeAsUpEnabled = isSubSettings; setTitleFromIntent(intent); Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); switchToFragment(initialFragmentName, initialArguments, true, false, mInitialTitleResId, mInitialTitle, false); } else { mDisplayHomeAsUpEnabled = false; mInitialTitleResId = R.string.app_name; switchToFragment(DashboardFragment.class.getName(), null, false, false, mInitialTitleResId, mInitialTitle, false); } } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled); actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled); } }
From source file:com.bullmobi.base.ui.activities.SettingsActivity.java
@Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); // Should happen before any call to getIntent() getMetaData();// w ww. java 2s. c o m final Intent intent = getIntent(); if (intent.hasExtra(EXTRA_UI_OPTIONS)) { getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); } // Getting Intent properties can only be done after the super.onCreate(...) final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false); final ComponentName cn = intent.getComponent(); final String className = cn.getClassName(); boolean isShowingDashboard = className.equals(Settings2.class.getName()); // This is a "Sub Settings" when: // - this is a real SubSettings // - or :settings:show_fragment_as_subsetting is passed to the Intent final boolean isSubSettings = className.equals(SubSettings.class.getName()) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false); // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets if (isSubSettings) { // Check also that we are not a Theme Dialog as we don't want to override them /* final int themeResId = getTheme(). getThemeResId(); if (themeResId != R.style.Theme_DialogWhenLarge && themeResId != R.style.Theme_SubSettingsDialogWhenLarge) { setTheme(R.style.Theme_SubSettings); } */ } setContentView(R.layout.settings_main_dashboard); mContent = (ViewGroup) findViewById(R.id.main_content); getSupportFragmentManager().addOnBackStackChangedListener(this); if (savedState != null) { // We are restarting from a previous saved state; used that to initialize, instead // of starting fresh. setTitleFromIntent(intent); ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES); if (categories != null) { mCategories.clear(); mCategories.addAll(categories); setTitleFromBackStack(); } mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP); } else { if (!isShowingDashboard) { mDisplayHomeAsUpEnabled = isSubSettings; setTitleFromIntent(intent); Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); switchToFragment(initialFragmentName, initialArguments, true, false, mInitialTitleResId, mInitialTitle, false); } else { mDisplayHomeAsUpEnabled = false; mInitialTitleResId = R.string.app_name; switchToFragment(DashboardFragment.class.getName(), null, false, false, mInitialTitleResId, mInitialTitle, false); } } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled); actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled); } }
From source file:com.hichinaschool.flashcards.anki.Feedback.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); Resources res = getResources(); Context context = getBaseContext(); SharedPreferences sharedPreferences = AnkiDroidApp.getSharedPrefs(context); mReportErrorMode = sharedPreferences.getString("reportErrorMode", REPORT_ASK); mNonce = UUID.randomUUID().getMostSignificantBits(); mFeedbackUrl = res.getString(R.string.feedback_post_url); mErrorUrl = res.getString(R.string.error_post_url); mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mPostingFeedback = false;//w ww.j a va 2 s . c om initAllAlertDialogs(); getErrorFiles(); Intent i = getIntent(); mAllowFeedback = (i.hasExtra("request") && (i.getIntExtra("request", 0) == DeckPicker.REPORT_FEEDBACK || i.getIntExtra("request", 0) == DeckPicker.RESULT_DB_ERROR)) || mReportErrorMode.equals(REPORT_ASK); if (!mAllowFeedback) { if (mReportErrorMode.equals(REPORT_ALWAYS)) { // Always report try { String feedback = "Automatically sent"; Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), true })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } } catch (Exception e) { Log.e(AnkiDroidApp.TAG, e.toString()); } finish(); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); } return; } else if (mReportErrorMode.equals(REPORT_NEVER)) { // Never report deleteFiles(false, false); finish(); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); } return; } } View mainView = getLayoutInflater().inflate(R.layout.feedback, null); setContentView(mainView); Themes.setWallpaper(mainView); Themes.setTextViewStyle(findViewById(R.id.tvFeedbackDisclaimer)); Themes.setTextViewStyle(findViewById(R.id.lvFeedbackErrorList)); Button btnSend = (Button) findViewById(R.id.btnFeedbackSend); Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest); Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll); mEtFeedbackText = (EditText) findViewById(R.id.etFeedbackText); mLvErrorList = (ListView) findViewById(R.id.lvFeedbackErrorList); mErrorAdapter = new SimpleAdapter(this, mErrorReports, R.layout.error_item, new String[] { "name", "state", "result" }, new int[] { R.id.error_item_text, R.id.error_item_progress, R.id.error_item_status }); mErrorAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { switch (view.getId()) { case R.id.error_item_progress: if (text.equals(STATE_UPLOADING)) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } return true; case R.id.error_item_status: if (text.length() == 0) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } return false; } }); btnClearAll.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, false); refreshErrorListView(); refreshInterface(); } }); mLvErrorList.setAdapter(mErrorAdapter); btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mPostingFeedback) { String feedback = mEtFeedbackText.getText().toString(); Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), false })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } refreshInterface(); } } }); btnKeepLatest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, true); refreshErrorListView(); refreshInterface(); } }); refreshInterface(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); }
From source file:com.pentacog.mctracker.MCServerTrackerActivity.java
/** * Used to collect new server data from the AddServer Activity * @see android.app.Activity#onActivityResult(int, int, android.content.Intent) *///from ww w .j a va 2 s. c o m @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == AddServerActivity.ADD_SERVER_ACTIVITY_ID && resultCode == RESULT_OK) { String serverName = data.getStringExtra(Server.SERVER_NAME); String serverAddress = data.getStringExtra(Server.SERVER_ADDRESS); String serverPort = data.getStringExtra(Server.SERVER_PORT); int serverId = data.getIntExtra(Server.SERVER_ID, -1); if (serverId == -1) { Server newServer = new Server(serverName, serverAddress); try { newServer.port = Integer.parseInt(serverPort); } catch (NumberFormatException e) { } getServerData(newServer); } else { Server server = serverList.getItem(serverId); server.name = serverName; server.address = serverAddress; try { server.port = Integer.parseInt(serverPort); } catch (NumberFormatException e) { } server.queried = false; serverList.sort(); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.betterAlarm.deskclock.DeskClock.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setVolumeControlStream(AudioManager.STREAM_ALARM); mIsFirstLaunch = (icicle == null);// w w w. j a v a2 s .co m getWindow().setBackgroundDrawable(null); mIsFirstLaunch = true; mSelectedTab = CLOCK_TAB_INDEX; if (icicle != null) { mSelectedTab = icicle.getInt(KEY_SELECTED_TAB, CLOCK_TAB_INDEX); mLastHourColor = icicle.getInt(KEY_LAST_HOUR_COLOR, UNKNOWN_COLOR_ID); if (mLastHourColor != UNKNOWN_COLOR_ID) { getWindow().getDecorView().setBackgroundColor(mLastHourColor); } } // Timer receiver may ask the app to go to the timer fragment if a timer expired Intent i = getIntent(); if (i != null) { int tab = i.getIntExtra(SELECT_TAB_INTENT_EXTRA, -1); if (tab != -1) { mSelectedTab = tab; } } initViews(); setHomeTimeZone(); // We need to update the system next alarm time on app startup because the // user might have clear our data. AlarmStateManager.updateNextAlarm(this); ExtensionsFactory.init(getAssets()); }
From source file:ir.aarani.bazaar.billing.BillingProcessor.java
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != PURCHASE_FLOW_REQUEST_CODE) return false; if (data == null) { Log.e(LOG_TAG, "handleActivityResult: data is null!"); return false; }//from ww w. j av a 2 s . c o m int responseCode = data.getIntExtra(Constants.RESPONSE_CODE, Constants.BILLING_RESPONSE_RESULT_OK); Log.d(LOG_TAG, String.format("resultCode = %d, responseCode = %d", resultCode, responseCode)); String purchasePayload = getPurchasePayload(); if (resultCode == Activity.RESULT_OK && responseCode == Constants.BILLING_RESPONSE_RESULT_OK && !TextUtils.isEmpty(purchasePayload)) { String purchaseData = data.getStringExtra(Constants.INAPP_PURCHASE_DATA); String dataSignature = data.getStringExtra(Constants.RESPONSE_INAPP_SIGNATURE); try { JSONObject purchase = new JSONObject(purchaseData); String productId = purchase.getString(Constants.RESPONSE_PRODUCT_ID); String developerPayload = purchase.getString(Constants.RESPONSE_PAYLOAD); if (developerPayload == null) developerPayload = ""; boolean purchasedSubscription = purchasePayload.startsWith(Constants.PRODUCT_TYPE_SUBSCRIPTION); if (purchasePayload.equals(developerPayload)) { if (verifyPurchaseSignature(productId, purchaseData, dataSignature)) { BillingCache cache = purchasedSubscription ? cachedSubscriptions : cachedProducts; cache.put(productId, purchaseData, dataSignature); if (eventHandler != null) eventHandler.onProductPurchased(productId, new TransactionDetails(new PurchaseInfo(purchaseData, dataSignature))); } else { Log.e(LOG_TAG, "Public key signature doesn't match!"); if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_INVALID_SIGNATURE, null); } } else { Log.e(LOG_TAG, String.format("Payload mismatch: %s != %s", purchasePayload, developerPayload)); if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_INVALID_SIGNATURE, null); } } catch (Exception e) { Log.e(LOG_TAG, "Error in handleActivityResult", e); if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_OTHER_ERROR, e); } } else { if (eventHandler != null) eventHandler.onBillingError(responseCode, null); } return true; }
From source file:de.j4velin.mapsmeasure.Map.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 42 && resultCode == RESULT_OK) { if (data.getIntExtra("RESPONSE_CODE", 0) == 0) { try { JSONObject jo = new JSONObject(data.getStringExtra("INAPP_PURCHASE_DATA")); PRO_VERSION = jo.getString("productId").equals("de.j4velin.mapsmeasure.pro") && jo.getString("developerPayload").equals(getPackageName()); getSharedPreferences("settings", Context.MODE_PRIVATE).edit().putBoolean("pro", PRO_VERSION) .commit();//from w ww.j av a2s. com changeType(MeasureType.ELEVATION); } catch (Exception e) { Toast.makeText(this, e.getClass().getName() + ": " + e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } } } }