Java Code Examples for android.os.Bundle#getString()

The following examples show how to use android.os.Bundle#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManageCourses.java    From android-apps with MIT License 6 votes vote down vote up
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);

}
 
Example 2
Source File: BaseActivity.java    From u2020-mvp with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: ViewerViewModel.java    From mvvm-template with GNU General Public License v3.0 6 votes vote down vote up
@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();
    }
}
 
Example 4
Source File: ConverterActivity.java    From ncalc with GNU General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example 5
Source File: RNDigits.java    From react-native-digits with MIT License 6 votes vote down vote up
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; 
}
 
Example 6
Source File: TokenCachingStrategy.java    From KlyphMessenger with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: PreferenceActivity.java    From AndroidPreferenceActivity with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 8
Source File: MyBooksFragment.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 9
Source File: BgService.java    From Women-Safety-App with GNU General Public License v2.0 5 votes vote down vote up
@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();
	
}
 
Example 10
Source File: MainFragment.java    From SimplePomodoro-android with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
        content = savedInstanceState.getString(KEY_CONTENT);
    }
}
 
Example 11
Source File: UpdateActivity.java    From indigenous-android with GNU General Public License v3.0 5 votes vote down vote up
@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);
            }
        }

    }
}
 
Example 12
Source File: MaskedEditText.java    From edittext-mask with MIT License 5 votes vote down vote up
@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);
}
 
Example 13
Source File: MyGcmListenerService.java    From friendlyping with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: PushReceiver.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 15
Source File: WikiPage.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
@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/");
}
 
Example 16
Source File: MarshallingTransformationListener.java    From LiTr with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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);
    }
}
 
Example 17
Source File: BaseActivity.java    From braintree-android-drop-in with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_AUTHORIZATION)) {
        mAuthorization = savedInstanceState.getString(KEY_AUTHORIZATION);
    }
}
 
Example 18
Source File: FragmentSB.java    From Pixiv-Shaft with MIT License 4 votes vote down vote up
@Override
public void initActivityBundle(Bundle bundle) {
    lastClass = bundle.getString(Params.LAST_CLASS);
}
 
Example 19
Source File: SettingsFragment.java    From BackPackTrackII with GNU General Public License v3.0 4 votes vote down vote up
@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();
}
 
Example 20
Source File: SearchActivity.java    From CrimeTalk-Reader with Apache License 2.0 3 votes vote down vote up
@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));

            }

        }

    }

}