Java Code Examples for android.content.Intent.getStringExtra()

The following are Jave code examples for showing how to use getStringExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: financisto1-holo   File: AbstractExportActivity.java   View Source Code Vote up 9 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	if (requestCode == 1) {
		if (resultCode == RESULT_FIRST_USER) {
			filter.clearDateTime();
		} else if (resultCode == RESULT_OK) {
			String periodType = data.getStringExtra(DateFilterActivity.EXTRA_FILTER_PERIOD_TYPE);
			PeriodType p = PeriodType.valueOf(periodType);
			if (PeriodType.CUSTOM == p) {
				long periodFrom = data.getLongExtra(DateFilterActivity.EXTRA_FILTER_PERIOD_FROM, 0);
				long periodTo = data.getLongExtra(DateFilterActivity.EXTRA_FILTER_PERIOD_TO, 0);
				filter.put(new DateTimeCriteria(periodFrom, periodTo));
			} else {
				filter.put(new DateTimeCriteria(p));
			}			
		}
		updatePeriod();
	}
}
 
Example 2
Project: AndroidSDK2.0   File: MainActivity.java   View Source Code Vote up 8 votes
@Override
protected void onActivityResult( int requestCode, int resultCode, Intent data )
{
	switch ( requestCode )
	{
		case REQUEST_CONNECT_DEVICE_SECURE:
			// When DeviceListActivity returns with a device to connect
			if ( resultCode == Activity.RESULT_OK )
			{
				String address = null;

				if ( (address = data.getStringExtra( DeviceListActivity.EXTRA_DEVICE_ADDRESS )) != null )
				{
					boolean isLe = data.getBooleanExtra( DeviceListActivity.EXTRA_IS_BLUETOOTH_LE, false);
					penClientCtrl.setLeMode(isLe);
					penClientCtrl.connect( address );
				}
			}
			break;
	}
}
 
Example 3
Project: AssistantBySDK   File: NaviSetLinePresenter.java   View Source Code Vote up 7 votes
@Override
public void initData(Intent intent, Handler handler) {
    this.intent = intent;
    mSetLineView.initView();

    calculatePreference = AppConfig.dPreferences.getInt(NaviSetLineActivity.CALCULATE_MODE, BaiduNaviManager.RoutePlanPreference.ROUTE_PLAN_MOD_RECOMMEND);
    preStartTips = mContext.getResources().getStringArray(R.array.navi_pre_start_tips);
    address = ((AppConfig) mContext.getApplication()).address;

    /* 初始化地图、导航引擎 */
    naviManager = new BaiduNaviSuperManager(mContext, naviInitListener, handler);
    this.mHandler = handler;
    if (this.intent != null) {
        int calculateMode = intent.getIntExtra("calculateMode", 0);
        if (calculateMode != 0)
            calculatePreference = calculateMode;
        passPoint = intent.getStringExtra("passPoint");
        mixCalculateType = (calculateType = intent.getIntExtra("type", 0));
        calculateRoad = intent.getIntExtra(NaviSetLineActivity.CALCULATE_ROAD, NaviSetLineActivity.UN_CALCULATE);
    }
}
 
Example 4
Project: TestChat   File: LoginActivity.java   View Source Code Vote up 7 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK) {
                switch (requestCode) {
                        case Constant.REQUEST_CODE_REGISTER:
                                String name = data.getStringExtra("username");
                                String password = data.getStringExtra("password");
                                if (name != null && password != null) {
                                        passWord.setText(password);
                                        userName.setText(name);
                                }
                                isFirstLogin = true;
                                break;
                }
        }
}
 
Example 5
Project: SecScanQR   File: HistoryDetailsActivity.java   View Source Code Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_history_details);
    tvCode = (TextView) findViewById(R.id.tvCodeHD);
    action_navigation = (BottomNavigationView) findViewById(R.id.history_action_navigation);
    BottomNavigationViewHelper.disableShiftMode(action_navigation);
    action_navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    historyDatabaseHelper = new DatabaseHelper(this);

    //Get the extra information from the history listview. and set the text in the textview eqaul to code
    Intent receivedIntent = getIntent();
    selectedID = receivedIntent.getIntExtra("id", -1); //-1 is the default value
    selectedCode = receivedIntent.getStringExtra("code");
    tvCode.setText(selectedCode);

}
 
Example 6
Project: pcloud-sdk-java   File: MainActivity.java   View Source Code Vote up 7 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == PCLOUD_AUTHORIZATION_REQUEST_CODE) {
        AuthorizationResult result = (AuthorizationResult) data.getSerializableExtra(AuthorizationActivity.KEY_AUTHORIZATION_RESULT);
        authorizationResultView.setText(result.name());

        if (result == AuthorizationResult.ACCESS_GRANTED) {
            String accessToken = data.getStringExtra(AuthorizationActivity.KEY_ACCESS_TOKEN);
            long userId = data.getLongExtra(AuthorizationActivity.KEY_USER_ID, 0);
            apiKeyView.setText(accessToken);
            //TODO: Do what's needed :)
        } else {
            //TODO: Add proper handling for denied grants or errors.
        }
    }
}
 
Example 7
Project: 3DPrintingProtocols   File: PrintingService.java   View Source Code Vote up 7 votes
@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (IPP_PRINT.equals(action)) {
            final String param1 = intent.getStringExtra(FILE_PATH);
            final String param2 = intent.getStringExtra(JOB_NAME);
            final String param3 = intent.getStringExtra(CONNECTION_TYPE);
            final String param4 = intent.getStringExtra(PRINTER_ADDRES);
            final int param5 = intent.getIntExtra(PRINTER_PORT,-1);
            final String param6 = intent.getStringExtra(PRINTER_URI);

            handleActionIppPrint(param1, param2, param3, param4, param5, param6);
        }
    }
}
 
Example 8
Project: Orin   File: MainActivity.java   View Source Code Vote up 6 votes
private long parseIdFromIntent(@NonNull Intent intent, String longKey,
                               String stringKey) {
    long id = intent.getLongExtra(longKey, -1);
    if (id < 0) {
        String idString = intent.getStringExtra(stringKey);
        if (idString != null) {
            try {
                id = Long.parseLong(idString);
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage());
            }
        }
    }
    return id;
}
 
Example 9
Project: Closet   File: WebContainerActivity.java   View Source Code Vote up 6 votes
private void handleIntent(){
    Intent intent = getIntent();
    if(intent != null){
        mUrl = intent.getStringExtra(HomeConstants.KEY_INTENT_ACTIVITY_WEB_URL);
        mHeaderTitle = intent.getStringExtra(HomeConstants.KEY_INTENT_ACTIVITY_HEADER_TITLE);
    }
}
 
Example 10
Project: android-project-gallery   File: BaiduNewsListActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	setContentView(R.layout.wrapper_news_main);

	Intent intent = getIntent();
	if (intent != null)
	{
		mTitle = intent.getStringExtra("title");
		mKeyword = intent.getStringExtra("keyword");
	}

	if (!TextUtils.isEmpty(mTitle))
	{
		setActionBarTitle(mTitle);
	}
	
	mImageLoader = ImageLoader.getInstance();
	mOptions = DisplayImageBuilder.getDefault()
				.cacheOnDisc(true)
				.considerExifParams(true)
				.bitmapConfig(Bitmap.Config.RGB_565)
				.displayer(new RoundedBitmapDisplayer(6))
				.build();

	doSearch(mKeyword, mPage);
}
 
Example 11
Project: AndroidPluggableTransportsDispatchService   File: DispatchReceiver.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    /* sanitize the Intent before forwarding it to TorService */
    String action = intent.getAction();
    if (TextUtils.equals(action, ACTION_START)) {
        String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);

            Intent startTorIntent = new Intent(context, DispatchService.class);
            startTorIntent.setAction(action);
            if (packageName != null)
                startTorIntent.putExtra(EXTRA_PACKAGE_NAME, packageName);
            context.startService(startTorIntent);

    }
}
 
Example 12
Project: Kids-Portal-Android   File: Fragment_Browser.java   View Source Code Vote up 6 votes
@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Uri[] results = null;
        // Check that the response is a good one
        if (requestCode == 1) {
            if(resultCode == RESULT_OK) {
                String strEditText = data.getStringExtra("editTextValue");

                if(strEditText.contains("true")){
                    showReports();
                }else{
                  // does nothing...
                }
            }
        }
        if (resultCode == RESULT_OK) {
            if (data == null) {
                // If there is not data, then we may have taken a photo
                if (mCameraPhotoPath != null) {
                    results = new Uri[]{Uri.parse(mCameraPhotoPath)};
                }
            } else {
                String dataString = data.getDataString();
                if (dataString != null) {

                    results = new Uri[]{Uri.parse(dataString)};
                }
            }
        }

//        mFilePathCallback.onReceiveValue(results);
        mFilePathCallback = null;
    }
 
Example 13
Project: react-native-udesk   File: UdeskChatActivity.java   View Source Code Vote up 6 votes
private void initIntent() {
    try {
        Intent intent = getIntent();
        if (intent != null) {
            groupId = intent.getStringExtra(UdeskConst.UDESKGROUPID);
            agentId = intent.getStringExtra(UdeskConst.UDESKAGENTID);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 14
Project: keepass2android   File: QRCodeEncoder.java   View Source Code Vote up 6 votes
private void encodeFromTextExtras(Intent intent) throws WriterException {
  // Notice: Google Maps shares both URL and details in one text, bummer!
  String theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_TEXT));
  if (theContents == null) {
    theContents = ContactEncoder.trim(intent.getStringExtra("android.intent.extra.HTML_TEXT"));
    // Intent.EXTRA_HTML_TEXT
    if (theContents == null) {
      theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_SUBJECT));
      if (theContents == null) {
        String[] emails = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
        if (emails != null) {
          theContents = ContactEncoder.trim(emails[0]);
        } else {
          theContents = "?";
        }
      }
    }
  }

  // Trim text to avoid URL breaking.
  if (theContents == null || theContents.isEmpty()) {
    throw new WriterException("Empty EXTRA_TEXT");
  }
  contents = theContents;
  // We only do QR code.
  format = BarcodeFormat.QR_CODE;
  if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
    displayContents = intent.getStringExtra(Intent.EXTRA_SUBJECT);
  } else if (intent.hasExtra(Intent.EXTRA_TITLE)) {
    displayContents = intent.getStringExtra(Intent.EXTRA_TITLE);
  } else {
    displayContents = contents;
  }
  title = activity.getString(R.string.contents_text);
}
 
Example 15
Project: SecScanQR   File: GenerateActivity.java   View Source Code Vote up 6 votes
/**
 * This method handles Text that was shared by an other app to SecScanQR and generates a qr code
 * @param intent from Share to from other Apps
 */
private void handleSendText(Intent intent){
    String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
    if(sharedText != null){
        text.setText(sharedText);
        text2Qr = sharedText;
    }
}
 
Example 16
Project: WeiXinRecordedDemo   File: CutSizeActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_cut_size);

    windowWidth = getWindowManager().getDefaultDisplay().getWidth();
    windowHeight = getWindowManager().getDefaultDisplay().getHeight();
    dp50 = (int) getResources().getDimension(R.dimen.dp50);

    initUI();

    Intent intent = getIntent();
    path = intent.getStringExtra("path");
    vv_play.setVideoPath(path);
    vv_play.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            vv_play.setLooping(true);
            vv_play.start();

            videoWidth = vv_play.getVideoWidth();
            videoHeight = vv_play.getVideoHeight();

            float ra = videoWidth*1f/videoHeight;

            float widthF = videoWidth*1f/MediaRecorderBase.VIDEO_HEIGHT;
            float heightF = videoHeight*1f/MediaRecorderBase.VIDEO_WIDTH;
            ViewGroup.LayoutParams layoutParams = vv_play.getLayoutParams();
            layoutParams.width = (int) (windowWidth*widthF);
            layoutParams.height = (int) (layoutParams.width/ra);
            vv_play.setLayoutParams(layoutParams);
        }
    });

    vv_play.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            cv_video.setMargin(vv_play.getLeft(), vv_play.getTop(), windowWidth-vv_play.getRight(), windowHeight-vv_play.getBottom()-dp50);
        }
    });
}
 
Example 17
Project: ComponentDemo   File: TrainActivity.java   View Source Code Vote up 5 votes
@Override
protected void initVariables() {
    Intent intent=getIntent();
    trainId = intent.getIntExtra("trainId", 0);
    trainName = intent.getStringExtra("trainName");
}
 
Example 18
Project: lineagex86   File: ZenModeRuleSettingsBase.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mContext = getActivity();

    final Intent intent = getActivity().getIntent();
    if (DEBUG) Log.d(TAG, "onCreate getIntent()=" + intent);
    if (intent == null) {
        Log.w(TAG, "No intent");
        toastAndFinish();
        return;
    }

    mRuleId = intent.getStringExtra(EXTRA_RULE_ID);
    if (DEBUG) Log.d(TAG, "mRuleId=" + mRuleId);
    if (refreshRuleOrFinish()) {
        return;
    }

    setHasOptionsMenu(true);

    onCreateInternal();

    final PreferenceScreen root = getPreferenceScreen();
    mRuleName = root.findPreference(KEY_RULE_NAME);
    mRuleName.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showRuleNameDialog();
            return true;
        }
    });

    mZenMode = (DropDownPreference) root.findPreference(KEY_ZEN_MODE);
    mZenMode.addItem(R.string.zen_mode_option_important_interruptions,
            Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
    mZenMode.addItem(R.string.zen_mode_option_alarms, Global.ZEN_MODE_ALARMS);
    mZenMode.addItem(R.string.zen_mode_option_no_interruptions,
            Global.ZEN_MODE_NO_INTERRUPTIONS);
    mZenMode.setCallback(new DropDownPreference.Callback() {
        @Override
        public boolean onItemSelected(int pos, Object value) {
            if (mDisableListeners) return true;
            final int zenMode = (Integer) value;
            if (zenMode == mRule.zenMode) return true;
            if (DEBUG) Log.d(TAG, "onPrefChange zenMode=" + zenMode);
            mRule.zenMode = zenMode;
            setZenModeConfig(mConfig);
            return true;
        }
    });
    mZenMode.setOrder(10);  // sort at the bottom of the category
    mZenMode.setDependency(getZenModeDependency());
}
 
Example 19
Project: GravityBox   File: BatteryStyleController.java   View Source Code Vote up 5 votes
@Override
public void onBroadcastReceived(Context context, Intent intent) {
    String action = intent.getAction();
    if (action.equals(GravityBoxSettings.ACTION_PREF_BATTERY_STYLE_CHANGED) &&
            intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_STYLE)) {
        mBatteryStyle = intent.getIntExtra(GravityBoxSettings.EXTRA_BATTERY_STYLE, 1);
        if (DEBUG) log("mBatteryStyle changed to: " + mBatteryStyle);
        updateBatteryStyle();
    } else if (action.equals(GravityBoxSettings.ACTION_PREF_BATTERY_PERCENT_TEXT_CHANGED)) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_STATUSBAR)) {
            mBatteryPercentTextEnabledSb = intent.getBooleanExtra(
                    GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_STATUSBAR, false);
            if (DEBUG)
                log("mBatteryPercentTextEnabledSb changed to: " + mBatteryPercentTextEnabledSb);
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_HEADER_HIDE)) {
            mBatteryPercentTextHeaderHide = intent.getBooleanExtra(
                    GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_HEADER_HIDE, false);
            if (DEBUG)
                log("mBatteryPercentTextHeaderHide changed to: " + mBatteryPercentTextHeaderHide);
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_KEYGUARD)) {
            mBatteryPercentTextKgMode = KeyguardMode.valueOf(intent.getStringExtra(
                    GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_KEYGUARD));
            if (DEBUG)
                log("mBatteryPercentTextEnabledKg changed to: " + mBatteryPercentTextKgMode);
        }
        updateBatteryStyle();
    } else if (action.equals(GravityBoxSettings.ACTION_PREF_BATTERY_PERCENT_TEXT_SIZE_CHANGED) &&
            intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_SIZE) && mPercentText != null) {
        int textSize = intent.getIntExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_SIZE, 0);
        mPercentText.setTextSize(textSize);
        if (DEBUG) log("PercentText size changed to: " + textSize);
    } else if (action.equals(GravityBoxSettings.ACTION_PREF_BATTERY_PERCENT_TEXT_STYLE_CHANGED)
            && mPercentText != null) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_STYLE)) {
            String percentSign = intent.getStringExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_STYLE);
            mPercentText.setPercentSign(percentSign);
            if (DEBUG) log("PercentText sign changed to: " + percentSign);
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_CHARGING)) {
            int chargingStyle = intent.getIntExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_CHARGING,
                    StatusbarBatteryPercentage.CHARGING_STYLE_NONE);
            mPercentText.setChargingStyle(chargingStyle);
            if (DEBUG) log("PercentText charging style changed to: " + chargingStyle);
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_CHARGING_COLOR)) {
            int chargingColor = intent.getIntExtra(
                    GravityBoxSettings.EXTRA_BATTERY_PERCENT_TEXT_CHARGING_COLOR, Color.GREEN);
            mPercentText.setChargingColor(chargingColor);
            if (DEBUG) log("PercentText charging color changed to: " + chargingColor);
        }
    } else if (action.equals(ACTION_MTK_BATTERY_PERCENTAGE_SWITCH)) {
        mMtkPercentTextEnabled = intent.getIntExtra(EXTRA_MTK_BATTERY_PERCENTAGE_STATE, 0) == 1;
        if (DEBUG) log("mMtkPercentText changed to: " + mMtkPercentTextEnabled);
        updateBatteryStyle();
    } else if (action.equals(GravityBoxSettings.ACTION_BATTERY_SAVER_CHANGED)) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BS_INDICATION_DISABLE)) {
            mBatterySaverIndicationDisabled = intent.getBooleanExtra(
                    GravityBoxSettings.EXTRA_BS_INDICATION_DISABLE, false);
            if (mCircleBattery != null && mCircleBattery.isAttachedToWindow()
                    && mContainerType == ContainerType.STATUSBAR) {
                mCircleBattery.postInvalidate();
            }
        }
    }
}
 
Example 20
Project: ProgressManager   File: a.java   View Source Code Vote up 3 votes
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}