コード例 #1
0
ファイル: Utilities.java プロジェクト: kim0z/gpslogger
  public static void SetFileExplorerLink(
      TextView txtFilename, Spanned htmlString, final String pathToLinkTo, final Context context) {

    final Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse("file://" + pathToLinkTo), "resource/folder");
    intent.setAction(Intent.ACTION_VIEW);

    if (intent.resolveActivity(context.getPackageManager()) != null) {
      txtFilename.setLinksClickable(true);
      txtFilename.setClickable(true);
      txtFilename.setMovementMethod(LinkMovementMethod.getInstance());
      txtFilename.setSelectAllOnFocus(false);
      txtFilename.setTextIsSelectable(false);
      txtFilename.setText(htmlString);

      txtFilename.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              context.startActivity(intent);
            }
          });
    }
  }
コード例 #2
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;
  }