PictureRecevier.java
public class PictureRecevier extends BroadcastReceiver {
private Context myContext;
@Override
public void onReceive(Context context, Intent intent) {
myContext = context;
Uri uri = intent.getData();
Log.i("Image Uri data ", uri.toString());
// example uri data is : content://media/external/images/media/1263
Log.i("Real image url is ", getRealPathFromURI(uri));
}
private String getRealPathFromURI(Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
CursorLoader loader = new CursorLoader(myContext, contentUri, proj,
null, null, null);
Cursor cursor = loader.loadInBackground();
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}
AndroidManifest.xml
............
<receiver
android:name="com.innoppl.mailme.PictureRecevier"
android:enabled="true" >
<intent-filter>
<action android:name="com.android.camera.NEW_PICTURE" />
<data android:mimeType="image/*" />
</intent-filter>
</receiver>
...........
No comments:
Post a Comment