Senhores, boa tarde!
Não estou conseguindo persistir a imagem no formulário. Até chega a aparecer a imagem no campo quando tiro a foto, mas quando vou editar, a imagem já nao esta mais lá...
Segue meus codigos:
FormularioActivity Metodos: onCreate e onActivityResult
@Override
public void onClick(View v) {
Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
caminhoFoto = getExternalFilesDir(null) + "/" +System.currentTimeMillis() + ".jpg";
File arquivoFoto = new File(caminhoFoto);
intentCamera.putExtra(MediaStore.EXTRA_OUTPUT,
FileProvider.getUriForFile(FormularioActivity.this,
BuildConfig.APPLICATION_ID + ".provider", arquivoFoto));
startActivityForResult(intentCamera, CODIGO_CAMERA);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CODIGO_CAMERA && resultCode == FormularioActivity.RESULT_OK) {
ImageView campoFoto = (ImageView) findViewById(R.id.formulario_foto);
Bitmap bitmap = BitmapFactory.decodeFile(caminhoFoto);
Bitmap bitmapReduzido = bitmap.createScaledBitmap(bitmap, 300, 300, true);
campoFoto.setImageBitmap(bitmapReduzido);
campoFoto.setTag(caminhoFoto);
}
}
provider_paths (o link a partir do "http://" esta em cinza, dizendo que nao esta em uso.
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="." />
</paths>
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.tcc.tcc">
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ListaPetsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FormularioActivity"
android:label="@string/title_activity_formulario"
/>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application>
</manifest>