android.os.Bundle#getString ( )源码实例Demo

下面列出了android.os.Bundle#getString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: u2020-mvp   文件: BaseActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    Bundle params = getIntent().getExtras();
    if (params != null) {
        onExtractParams(params);
    }

    if (savedInstanceState != null && savedInstanceState.containsKey(BF_UNIQUE_KEY)) {
        uniqueKey = savedInstanceState.getString(BF_UNIQUE_KEY);
    } else {
        uniqueKey = UUID.randomUUID().toString();
    }

    super.onCreate(savedInstanceState);

    U2020App app = U2020App.get(this);
    onCreateComponent(app.component());
    if (viewContainer == null) {
        throw new IllegalStateException("No injection happened. Add component.inject(this) in onCreateComponent() implementation.");
    }
    Registry.add(this, viewId(), presenter());
    final LayoutInflater layoutInflater = getLayoutInflater();
    ViewGroup container = viewContainer.forActivity(this);
    layoutInflater.inflate(layoutId(), container);
}
 
源代码2 项目: ncalc   文件: ConverterActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_unit_converter_child);

    Intent intent = getIntent();
    Bundle bundle = intent.getBundleExtra("data");
    int pos = bundle.getInt("POS");
    String name = bundle.getString("NAME");

    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle(name);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    initView();
    setUpSpinnerAndStratery(pos);
}
 
源代码3 项目: KlyphMessenger   文件: TokenCachingStrategy.java
/**
 * Returns a boolean indicating whether a Bundle contains properties that
 * could be a valid saved token.
 * 
 * @param bundle
 *            A Bundle to check for token information.
 * @return a boolean indicating whether a Bundle contains properties that
 *         could be a valid saved token.
 */
public static boolean hasTokenInformation(Bundle bundle) {
    if (bundle == null) {
        return false;
    }

    String token = bundle.getString(TOKEN_KEY);
    if ((token == null) || (token.length() == 0)) {
        return false;
    }

    long expiresMilliseconds = bundle.getLong(EXPIRATION_DATE_KEY, 0L);
    if (expiresMilliseconds == 0L) {
        return false;
    }

    return true;
}
 
源代码4 项目: react-native-digits   文件: RNDigits.java
private String getMetaData(String name) {
  try {
    ApplicationInfo ai = mContext.getPackageManager().getApplicationInfo(
      mContext.getPackageName(),
      PackageManager.GET_META_DATA
    );

    Bundle metaData = ai.metaData;
    if(metaData == null) {
      Log.w(TAG, "metaData is null. Unable to get meta data for " + name);
    } else {
      String value = metaData.getString(name);
      return value;
    }
  } catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
  }
  return null; 
}
 
源代码5 项目: mvvm-template   文件: ViewerViewModel.java
@Override
protected void onFirsTimeUiCreate(@Nullable Bundle intent) {
    if (intent == null) return;
    isRepo = intent.getBoolean(BundleConstant.EXTRA);
    url = intent.getString(BundleConstant.ITEM);
    htmlUrl = intent.getString(BundleConstant.EXTRA_TWO);
    if (!InputHelper.isEmpty(url)) {
        if (MarkDownProvider.isArchive(url)) {
            publishState(State.error(App.getInstance().getString(R.string.archive_file_detected_error)));
            return;
        }
        if (isRepo) {
            url = url.endsWith("/") ? (url + "readme") : (url + "/readme");
        }
        onWorkOnline();
    }
}
 
源代码6 项目: android-apps   文件: ManageCourses.java
private void initialControls() {
	departCode = (TextView) findViewById(R.id.viewCodeD);
	departName = (TextView) findViewById(R.id.viewNameD);

	txtCourseTitle = (EditText) findViewById(R.id.txtCodeC);
	txtCourseName = (EditText) findViewById(R.id.txtNameC);

	btnAddC = (Button) findViewById(R.id.addCourse);
	btnUpdateC = (Button) findViewById(R.id.updateCourse);

	Bundle extras = getIntent().getExtras();
	if (extras != null) {
		departmentCode = extras.getString("depCode");
		departmentName = extras.getString("depName");
	}
	departCode.setText(departmentCode);
	departName.setText(departmentName);

}
 
源代码7 项目: indigenous-android   文件: UpdateActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_update);
    super.onCreate(savedInstanceState);

    // Get default user.
    user = new Accounts(this).getDefaultUser();

    layout = findViewById(R.id.update_root);
    url = findViewById(R.id.url);
    postStatus = findViewById(R.id.postStatus);
    title = findViewById(R.id.title);
    body = findViewById(R.id.body);

    // Set listener.
    VolleyRequestListener(this);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {

        String status = extras.getString("status");
        if (status != null && status.equals("draft")) {
            postStatus.setChecked(false);
        }

        String urlToUpdate = extras.getString("url");
        if (urlToUpdate != null && urlToUpdate.length() > 0) {
            if (URLUtil.isValidUrl(urlToUpdate)) {
                url.setText(urlToUpdate);
                getPostFromServer(urlToUpdate);
            }
        }

    }
}
 
源代码8 项目: braintree-android-drop-in   文件: BaseActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_AUTHORIZATION)) {
        mAuthorization = savedInstanceState.getString(KEY_AUTHORIZATION);
    }
}
 
源代码9 项目: LiTr   文件: MarshallingTransformationListener.java
@Override
public void handleMessage(@NonNull Message message) {
    List<TrackTransformationInfo> trackTransformationInfos = message.obj == null ? null : (List<TrackTransformationInfo>) message.obj;

    Bundle data = message.getData();
    String jobId = data.getString(KEY_JOB_ID);
    if (jobId == null) {
        throw new IllegalArgumentException("Handler message doesn't contain an id!");
    }

    switch (message.what) {
        case EVENT_STARTED: {
            listener.onStarted(jobId);
            break;
        }
        case EVENT_COMPLETED: {
            listener.onCompleted(jobId, trackTransformationInfos);
            break;
        }
        case EVENT_CANCELLED: {
            listener.onCancelled(jobId, trackTransformationInfos);
            break;
        }
        case EVENT_ERROR: {
            Throwable cause = (Throwable) data.getSerializable(KEY_THROWABLE);
            listener.onError(jobId, cause, trackTransformationInfos);
            break;
        }
        case EVENT_PROGRESS: {
            float progress = data.getFloat(KEY_PROGRESS);
            listener.onProgress(jobId, progress);
            break;
        }
        default:
            Log.e(TAG, "Unknown event received: " + message.what);
    }
}
 
源代码10 项目: Slide   文件: WikiPage.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = this.getArguments();
    title = bundle.getString("title", "");
    subreddit = bundle.getString("subreddit", "");
    wikiUrl = "https://www.reddit.com/r/".concat(subreddit).concat("/wiki/");
}
 
源代码11 项目: MyHearts   文件: PushReceiver.java
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    Log.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));

    if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
        String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
        Log.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
        //send the Registration Id to your server...

    } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
        Log.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
        processCustomMessage(context, bundle);

    } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
        Log.d(TAG, "[MyReceiver] 接收到推送下来的通知");
        int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
        Log.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);

    } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
        Log.d(TAG, "[MyReceiver] 用户点击打开了通知");

        //打开自定义的Activity
        Intent i = new Intent(context, PushActivity.class);
        i.putExtras(bundle);
        //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
        context.startActivity(i);

    } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
        Log.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
        //在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..

    } else if(JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
        boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
        Log.w(TAG, "[MyReceiver]" + intent.getAction() +" connected state change to "+connected);
    } else {
        Log.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
    }
}
 
源代码12 项目: friendlyping   文件: MyGcmListenerService.java
private ArrayList<Pinger> getPingers(Bundle data) throws JSONException {
    final JSONArray clients = new JSONArray(data.getString("clients"));
    ArrayList<Pinger> pingers = new ArrayList<>(clients.length());
    for (int i = 0; i < clients.length(); i++) {
        JSONObject jsonPinger = clients.getJSONObject(i);
        pingers.add(Pinger.fromJson(jsonPinger));
    }
    return pingers;
}
 
源代码13 项目: edittext-mask   文件: MaskedEditText.java
@Override
public void onRestoreInstanceState(Parcelable state) {
	Bundle bundle = (Bundle) state;
	keepHint = bundle.getBoolean("keepHint", false);
	super.onRestoreInstanceState(((Bundle) state).getParcelable("super"));
	final String text = bundle.getString("text");

	setText(text);
	Log.d(TAG, "onRestoreInstanceState: " + text);
}
 
/**
 * Handles the intent extra, which specifies the text of the next button.
 *
 * @param extras
 *         The extras of the intent, which has been used to start the activity, as an instance
 *         of the class {@link Bundle}. The bundle may not be null
 */
private void handleNextButtonTextIntent(@NonNull final Bundle extras) {
    CharSequence text = extras.getString(EXTRA_NEXT_BUTTON_TEXT);

    if (!TextUtils.isEmpty(text)) {
        setNextButtonText(text);
    }
}
 
源代码15 项目: SimplePomodoro-android   文件: MainFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
        content = savedInstanceState.getString(KEY_CONTENT);
    }
}
 
源代码16 项目: Women-Safety-App   文件: BgService.java
@Override
public void handleMessage(Message message) {
	
	Toast.makeText(getApplicationContext(), "geocoderhandler started", Toast.LENGTH_SHORT).show();

 
    switch (message.what) {
        case 1:
            Bundle bundle = message.getData();
            str_address = bundle.getString("address");
           // TelephonyManager tmgr=(TelephonyManager)BgService.this.getSystemService(Context.TELEPHONY_SERVICE);
          //  String ph_number=tmgr.getLine1Number();
        	SQLiteDatabase db;
    		db=openOrCreateDatabase("NumDB", Context.MODE_PRIVATE, null);
    		Cursor c=db.rawQuery("SELECT * FROM details", null);
    		Cursor c1=db.rawQuery("SELECT * FROM SOURCE", null); 
        
            String source_ph_number=c1.getString(0);
              while(c.moveToNext())
 		   {
 		      String target_ph_number=c.getString(1);
 		    
    //         SmsManager smsManager=SmsManager.getDefault();
    //         smsManager.sendTextMessage("+918121662586", "+918121662586", "Please help me. I need help immediately. This is where i am now:"+str_address, null, null);
             
         	Toast.makeText(getApplicationContext(), "Source:"+source_ph_number+"Target:"+target_ph_number, Toast.LENGTH_SHORT).show();

 		   } 
              db.close();
        
            break;
        default:
        	str_address = null;
    }
	Toast.makeText(getApplicationContext(), str_address, Toast.LENGTH_SHORT).show();
	
}
 
源代码17 项目: barterli_android   文件: MyBooksFragment.java
@Override
public View onCreateView(final LayoutInflater inflater,
                         final ViewGroup container, final Bundle savedInstanceState) {
    init(container, savedInstanceState);
    setHasOptionsMenu(true);
    mLoadedIndividually = false;
    final View view = inflater
            .inflate(R.layout.fragment_profile_books, null);

    mGridProfileBooks = (GridView) view
            .findViewById(R.id.grid_profile_books);

    if (savedInstanceState != null) {
        final String savedUserId = savedInstanceState
                .getString(Keys.USER_ID);

        if (!TextUtils.isEmpty(savedUserId)) {
            setUserId(savedUserId);
        }
    } else {
        final Bundle extras = getArguments();

        if (extras != null && extras.containsKey(Keys.USER_ID)) {
            setUserId(extras.getString(Keys.USER_ID));
        }
    }

    mProfileBooksAdapter = new BooksGridAdapter(getActivity(), false);
    mGridProfileBooks.setAdapter(mProfileBooksAdapter);

    mGridProfileBooks.setOnItemClickListener(this);

    return view;
}
 
源代码18 项目: Pixiv-Shaft   文件: FragmentSB.java
@Override
public void initActivityBundle(Bundle bundle) {
    lastClass = bundle.getString(Params.LAST_CLASS);
}
 
源代码19 项目: BackPackTrackII   文件: SettingsFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    running = true;

    addPreferencesFromResource(R.xml.preferences);

    db = new DatabaseHelper(getActivity());

    // Shared geo point
    Uri data = getActivity().getIntent().getData();
    if (data != null && "geo".equals(data.getScheme())) {
        Intent geopointIntent = new Intent(getActivity(), BackgroundService.class);
        geopointIntent.setAction(BackgroundService.ACTION_GEOPOINT);
        geopointIntent.putExtra(BackgroundService.EXTRA_GEOURI, data);
        getActivity().startService(geopointIntent);

        edit_waypoints();
    }

    Bundle extras = getActivity().getIntent().getExtras();
    if (extras != null && extras.containsKey(EXTRA_ACTION)) {
        String action = extras.getString(EXTRA_ACTION);
        if (ACTION_LOCATION.equals(action))
            location_history();
        else if (ACTION_STEPS.equals(action))
            step_history();
        else if (ACTION_WEATHER.equals(action))
            weather_history();
        else if (ACTION_FORECAST.equals(action))
            weather_forecast();
    }

    if (Util.hasPlayServices(getActivity()))
        new Thread(new Runnable() {
            @Override
            public void run() {
                Log.i(TAG, "Connecting to Play services");
                GoogleApiClient gac = new GoogleApiClient.Builder(getActivity()).addApi(ActivityRecognition.API).build();
                ConnectionResult result = gac.blockingConnect();
                if (result.isSuccess())
                    Log.i(TAG, "Connected to Play services");
                else {
                    Log.w(TAG, "Error connecting to Play services, error=" + result.getErrorMessage() + " resolution=" + result.hasResolution());
                    if (result.hasResolution())
                        try {
                            result.startResolutionForResult(getActivity(), ACTIVITY_PLAY_SERVICES);
                        } catch (IntentSender.SendIntentException ex) {
                            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                        }
                    else
                        Util.toast(result.getErrorMessage(), Toast.LENGTH_SHORT, getActivity());
                }
            }
        }).start();
}
 
源代码20 项目: CrimeTalk-Reader   文件: SearchActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    ThemeUtils.setTheme(this, true);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    // Modify various attributes of the Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    // Set the search text hint
    ((TextView) findViewById(R.id.search)).setText(getIntent().getExtras().getString(ARG_SEARCH_TEXT));

    // Grab the previous query from orientation change
    if (savedInstanceState != null) {

        this.mQuery = savedInstanceState.getString(ARG_QUERY);

        // Restore text in search hint if it exists
        if(mQuery != null && !mQuery.isEmpty()) {

            if (getIntent().getExtras().getString(ARG_SEARCH_TEXT).equals(getResources().getString(R.string.search_library))) {

                ((TextView) findViewById(R.id.search)).setText(String.format(getResources().getString(R.string.searching_library_for),
                        mQuery));

            } else {

                ((TextView) findViewById(R.id.search)).setText(String.format(getResources().getString(R.string.searching_press_cuttings_for),
                        mQuery));

            }

        }

    }

}