android 在一个类中调用另一个类中的方法问题
如:我在A中调用B中的一个方法;B中的方法:privatevoidshowSelectPictureDialog(){if(isExistSDCard()){photof...
如:我在A中调用B中的一个方法;
B中的方法:
private void showSelectPictureDialog() {
if (isExistSDCard()) {
photofileName = "APDF_" + edtCode.getText().toString() + "_" + application.getCurrentUser().getUserID() + "_" + new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date()) + ".jpg";
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File dir = new File(ZhiRenApplication.SECOND_PATH);
if (!dir.exists()) {
dir.mkdirs();
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(dir, photofileName)));
startActivityForResult(intent, TAKE_IMAGE_FOR_CAMERA);
} else {
Toast.makeText(SendScanActivity.this, getString(R.string.not_found_sdcard), Toast.LENGTH_LONG).show();
}
}
我在A中这样调用会出错:
case R.id.center_photo:
SendScanActivity sendscan = new SendScanActivity();
sendscan.getSendScanActivity();
break;
private void showSelectPictureDialog 我后面修改成public void getSendScanActivity 展开
B中的方法:
private void showSelectPictureDialog() {
if (isExistSDCard()) {
photofileName = "APDF_" + edtCode.getText().toString() + "_" + application.getCurrentUser().getUserID() + "_" + new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date()) + ".jpg";
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File dir = new File(ZhiRenApplication.SECOND_PATH);
if (!dir.exists()) {
dir.mkdirs();
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(dir, photofileName)));
startActivityForResult(intent, TAKE_IMAGE_FOR_CAMERA);
} else {
Toast.makeText(SendScanActivity.this, getString(R.string.not_found_sdcard), Toast.LENGTH_LONG).show();
}
}
我在A中这样调用会出错:
case R.id.center_photo:
SendScanActivity sendscan = new SendScanActivity();
sendscan.getSendScanActivity();
break;
private void showSelectPictureDialog 我后面修改成public void getSendScanActivity 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询