manifestu kod:
<receiver android:name=".pictureReceiver" >
<intent-filter android:priority="10000" >
<action android:name="com.android.camera.NEW_PICTURE"/>
<data android:mimeType="image/*"/>
</intent-filter>
</receiver>
onReceive Kod:
@Override
public void onReceive(Context arg0, Intent arg1) {
String selectedImageUri = arg1.getData().getPath();
Log.d("TAG", "Received new photo:::"+selectedImageUri);
Log.d("TAG","file Path"+getRealPathFromURI(arg1.getData(),arg0));
}
public String getRealPathFromURI(Uri contentUri,Context context)
{
try
{
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
catch (Exception e)
{
return contentUri.getPath();
}
}
Próbowałem edytować twoje pytanie najlepiej jak to zrozumiałem; ale musisz wyjaśnić, co chcesz zrobić. Spróbuj zaktualizować pytanie, wykonując serię kroków, które użytkownik ma wykonać. Na przykład 1. Otwórz moją aplikację 2. Kliknij przycisk aparatu 2. Moja aplikacja pokazuje widok aparatu 3. Użytkownik przechwytuje obraz przy użyciu mojej aplikacji. –