示例#1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;
    switch (item.getItemId()) {
      case android.R.id.home:
        savaDraft();
        InputMethodManager imm =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive())
          imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
        intent = new Intent(this, MainTimeLineActivity.class);
        intent.putExtra("account", getAccount());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        break;
      case R.id.menu_emoticon:
        EmotionsGridDialog dialog = new EmotionsGridDialog();
        dialog.show(getFragmentManager(), "");
        break;

      case R.id.menu_topic:
        String ori = content.getText().toString();
        String topicTag = "##";
        content.setText(ori + topicTag);
        content.setSelection(content.getText().toString().length() - 1);
        break;
      case R.id.menu_at:
        intent = new Intent(WriteWeiboActivity.this, AtUserActivity.class);
        intent.putExtra("token", token);
        startActivityForResult(intent, AT_USER);
        break;
    }
    return true;
  }
示例#2
0
  protected void executeTask(String content) {

    if (TextUtils.isEmpty(picPath)) {
      new StatusNewTask(content).executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
    } else {
      Intent intent = new Intent(WriteWeiboActivity.this, UploadPhotoService.class);
      intent.putExtra("token", token);
      intent.putExtra("picPath", picPath);
      if (!content.equals(getLastContent())) {
        intent.putExtra("content", content);
      } else {
        intent.putExtra("content", content + " ");
      }
      intent.putExtra("geo", geoBean);
      startService(intent);
      finish();
    }
  }
示例#3
0
 public void addEnvToIntent(Intent intent) {
   Map<String, String> envMap = System.getenv();
   Set<Map.Entry<String, String>> envSet = envMap.entrySet();
   Iterator<Map.Entry<String, String>> envIter = envSet.iterator();
   int c = 0;
   while (envIter.hasNext()) {
     Map.Entry<String, String> entry = envIter.next();
     intent.putExtra("env" + c, entry.getKey() + "=" + entry.getValue());
     c++;
   }
 }
  private void finishWithPath(String path) {
    if (pathSettingKey != null && !pathSettingKey.isEmpty()) {
      SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
      SharedPreferences.Editor editor = settings.edit();
      editor.putString(pathSettingKey, path);
      editor.commit();
    }

    Intent intent = new Intent();
    intent.putExtra("PATH", path);
    setResult(RESULT_OK, intent);
    finish();
  }
示例#5
0
  @Override
  public void onClick(DialogInterface dialog, int which) {

    switch (which) {
      case 0:
        imageFileUri =
            getContentResolver()
                .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
        Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
        startActivityForResult(i, CAMERA_RESULT);
        break;
      case 1:
        Intent choosePictureIntent =
            new Intent(
                Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(choosePictureIntent, PIC_RESULT);
        break;
    }
  }