2016-08-06 15 views
0
@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    // Check which request we're responding to 
    if (requestCode == PICK_CONTACT_REQUEST) { 
     // Make sure the request was successful 
     if (resultCode == RESULT_OK) { 
      //Button Click 
     } 
    } 
} 

ここではRESULT_OKなら、ボタンをクリックして何をしたいのですか?私はif(getTaskId()==R.id.PassImageBtn){}を使用しましたが、ボタンをクリックしても何も起こっていません。androidアプリケーションのカメラから画像をキャプチャした後、onActivityResult()内のボタンをクリックしてください

+0

ボタンをクリックする必要がありますか?あなたはそのボタンをクリックして何をしているのかを行うための機能を作成することができます。 –

+0

実際には、ユーザー入力に基づいて画像をトリミングしたいと考えています。つまりパスポートサイズとスタンプサイズ。私はボタンをクリックしたい。私は固定サイズの作物が欲しいので、私は私のアプリでこのリンクコードを実装している:https://github.com/oginotihiro/cropview私はこれを使っています。 – Amshu

+0

Uri tempUri = getImageUri(getApplicationContext()、photo); ファイルfinalFile =新しいファイル(getRealPathFromURI(tempUri));int x =(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP、100、getResources()。getDisplayMetrics());int y =(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP、100、getResources()。getDisplayMetrics()); // cropView.of(source).withAspect(x、y).initialize(MainActivity.this); cropView.of(Uri.fromFile(finalFile))。withAspect(x、y).initialize(StudentDetails.this); – Amshu

答えて

0

コールボタンクリックイベントに対してperformClick()メソッドを使用します。

private Button mButton; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.my_layout); 
    mButton = findViewById(R.id.my_button); 
    mButton.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View v) { 
      // ... 
     } 
    }); 
} 

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    // Check which request we're responding to 
    if (requestCode == PICK_CONTACT_REQUEST) { 
     // Make sure the request was successful 
     if (resultCode == RESULT_OK) { 
      mButton.performClick(); 
     } 
    } 
} 
関連する問題