2016-09-08 8 views
2

私の携帯電話をAndroidのnougatにアップデートして、機能の作物が突然動かない。マシュマロで完全に働いた。 これは私のbuild.gradleandroid Nougatの画像を切り取る

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 24 
buildToolsVersion "24.0.1" 
defaultConfig { 
    applicationId "multas.com.usj.multaszgz" 
    minSdkVersion 23 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    multiDexEnabled true 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile project(':tess-two-release') 
compile files('libs/androidjhlabs.jar') 
//Pestañas 
compile files('libs/commons-codec-1.7.jar') 
compile project(path: ':openCVLibrary310') 
compile 'com.android.support:appcompat-v7:24.2.0' 
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4' 
compile 'com.android.support:design:24.2.0' 
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' 
compile 'com.google.code.gson:gson:2.3.1' 
compile 'com.itextpdf:itextg:5.5.9' 
compile 'org.codepond:wizardroid:1.3.1' 
compile 'com.google.android.gms:play-services:9.4.0' 
testCompile 'junit:junit:4.12' 
} 

であり、これは、作物のためのコードです:

private void crop(){ 
try { 

    Log.v("OCRActivity", "HA LLEGADO AL CROP: "+takeStoragePermissionGranted()); 
    File file = new File(path); 
    Uri outputFileUri = Uri.fromFile(file); 

    Intent intent = new Intent("com.android.camera.action.CROP"); 
    intent.setDataAndType(outputFileUri, "image/*"); 
    intent.putExtra("crop", true); 
    //intent.putExtra("outputX",bm.getWidth()); 
    //intent.putExtra("outputY", bm.getHeight()); 
    intent.putExtra("aspectX", 0); 
    intent.putExtra("aspectY", 0); 
    intent.putExtra("scale", true); 
    intent.putExtra("return-data", true); 
    Log.v("OCRActivity", "HA LLEGADO "); 

    startActivityForResult(intent, PIC_CROP); 

} 
catch(ActivityNotFoundException anfe){ 
    //display an error message 
    String errorMessage = "Whoops - your device doesn't support the crop action!"; 
    Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT); 
    toast.show(); 
}catch(Exception e){ 
    Log.e("OCRActivity", "crop():"+e.getMessage()); 
} 

    } 

が、私は、コンソールにエラーを検出いけないが、それは1でなければならないときonActivityOnResultでのResultCode = 0を返します... マシュマロでうまくいかないことはわかっていません...

どれでも解決してください。

+0

[Androidには 'CROP'' Intent'がありません](https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html)。多くの[Android用画像トリミングライブラリ](https://android-arsenal.com/tag/45)があります。 1つを使用してください。 – CommonsWare

+0

ありがとうございました!ですから、今私の質問は...アンドロイドのヌガーにAOSPカメラを含めることはできますか?私はこのアプリは私のために、任意の電話やユーザーのためではないので、作物のためのライブラリをインポートしたいと思います。 –

+0

最後に私はこのカメラの.apk(http://www.qbking77.com/apps-games/download-the-camera-and-live-wallpaper-from-google-play-edition-devices/)をインストールしました。完璧でした!作物の意図については、CommonsWareに感謝します。私が見ているすべてのサイトで、情報は、camera.action.cropがアンドロイドの指示だったかのように表示されます... –

答えて

0

私のAndroidプロジェクトでこの機能を使用しています。 うまくいけば助けてください。パッケージのドメイン外// URIはアクセス不能パスと受信機を残すことがあります。ファイルを渡すのAndroid -Nからイメージ

private void croppingIMG() { 
    imageSelect = true; 
    final ArrayList cropOptions = new ArrayList(); 
    Intent intent = new Intent("com.android.camera.action.CROP"); 
    intent.setType("image/*"); 

    List list = getActivity().getPackageManager().queryIntentActivities(intent, 0); 
    int size = list.size(); 
    if (size == 0) { 
     Toast.makeText(getActivity(), "Cann't find image croping app", Toast.LENGTH_SHORT).show(); 
     return; 
    } else { 
     intent.setData(mImageCaptureUri); 
     intent.putExtra("outputX", 512); 
     intent.putExtra("outputY", 512); 
     intent.putExtra("aspectX", 1); 
     intent.putExtra("aspectY", 1); 
     intent.putExtra("scale", true); 
     //TODO: don't use return-data tag because it's not return large image data and crash not given any message 
     intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outPutFile)); 

     if (size == 1) { 
      Intent i = new Intent(intent); 
      ResolveInfo res = (ResolveInfo) list.get(0); 
      i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); 
      startActivityForResult(i, CROPING_CODE); 
     } else { 

      Intent i = new Intent(intent); 
      ResolveInfo res = (ResolveInfo) list.get(0); 
      i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); 
      startActivityForResult(i, CROPING_CODE); 
     } 
    } 
} 
0

をCROPING FOR

// FUNCTION。したがって、file:// URIを渡すと、FileUriExposedExceptionがトリガーされます。

詳細はarticleを参照してください。

ことの一つはまた、あなたがAPIのためのギャラリーから画像を選択しながら、あなたの作物の意図に出力URIを追加する必要がありますのでご注意などの> = 24、

intent.putExtra(MediaStore.EXTRA_OUTPUT、Uri.fromFile(YOUR_FILE_PATH) );

関連する問題