Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can solve : java.lang.ClassCastException: android.graphics.Bitmap cannot be cast to android.net.Uri
    primarykey
    data
    text
    <p>when time to i share image on whats app facebook ect. its failed to file read and throw exeption Caused by: </p> <pre><code>java.lang.ClassCastException: android.graphics.Bitmap cannot be cast to android.net.Uri 11-23 12:32:02.835: E/AndroidRuntime(11662): at com.whatsapp.ContactPicker.d(ContactPicker.java:531) 11-23 12:32:02.835: E/AndroidRuntime(11662): at com.whatsapp.ContactPicker.onCreate(ContactPicker.java:306) 11-23 12:32:02.835: E/AndroidRuntime(11662): at android.app.Activity.performCreate(Activity.java:4479) 11-23 12:32:02.835: E/AndroidRuntime(11662): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050) 11-23 12:32:02.835: E/AndroidRuntime(11662): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041) </code></pre> <p>My activity: </p> <pre><code>public class FullImageActivity extends Activity { ImageView imageView; Button buttonsetwallpaper, share; String sp_items[] = new String[] { "Setwallpaper", "Share", "Exit" }; Spinner spinner; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.full_image); buttonsetwallpaper = (Button) findViewById(R.id.wallpaper); buttonsetwallpaper.getBackground().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY); share = (Button) findViewById(R.id.button2); // get intent data Intent i = getIntent(); final int position = i.getExtras().getInt("id"); final ImageAdapter imageAdapter = new ImageAdapter(this); imageView = (ImageView) findViewById(R.id.full_image_view); imageView.setImageResource(imageAdapter.mThumbIds[position]); share.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View arg0) { // Bitmap o = BitmapFactory.decodeFile("/sdcard/." + img_name); // Bitmap o = // BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/wallpaperapp/"); Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), imageAdapter.mThumbIds[position]); // Bitmap mBitmap = // BitmapFactory.decodeResource(getResources(),(int)i.getItemId(position)); try { Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/png"); System.out.println("*********************" + mBitmap); share.putExtra( Intent.EXTRA_STREAM, scaleDownBitmap(mBitmap, 90, FullImageActivity.this)); startActivity(Intent.createChooser(share, "Share Image")); } catch (Exception e) { e.printStackTrace(); // Toast.makeText(FullImageActivity.this, // "Error setting wallpaper", Toast.LENGTH_SHORT).show(); } } }); buttonsetwallpaper.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View arg0) { // Bitmap o = BitmapFactory.decodeFile("/sdcard/." + img_name); // Bitmap o = // BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/wallpaperapp/"); Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), imageAdapter.mThumbIds[position]); // Bitmap mBitmap = // BitmapFactory.decodeResource(getResources(),(int)i.getItemId(position)); WallpaperManager myWallpaperManager = WallpaperManager .getInstance(getApplicationContext()); try { myWallpaperManager.setBitmap(mBitmap); Toast.makeText(FullImageActivity.this, "Wallpaper set", Toast.LENGTH_SHORT).show(); } catch (IOException e) { Toast.makeText(FullImageActivity.this, "Error setting wallpaper", Toast.LENGTH_SHORT) .show(); } } }); } Bitmap scaleDownBitmap(Bitmap photo, int newHeight, Context context) { final float densityMultiplier = context.getResources() .getDisplayMetrics().density; int h = (int) (newHeight * densityMultiplier); int w = (int) (h * photo.getWidth() / ((double) photo.getHeight())); photo = Bitmap.createScaledBitmap(photo, w, h, true); return photo; } </code></pre> <hr> <p>my image in layout folder with save into sdcard i want to share here i give my code plz help me. </p> <pre><code>public class ImageAdapter extends BaseAdapter { private Context mContext; ImageView imageView; // Keep all Images in array public Integer[] mThumbIds = { R.drawable.a1, R.drawable.a2, R.drawable.a3, R.drawable.a10, R.drawable.a11, R.drawable.a12, R.drawable.a13, R.drawable.a14, R.drawable.a15, R.drawable.a16, R.drawable.a17, R.drawable.a18, R.drawable.a19, R.drawable.a20, R.drawable.a21, R.drawable.a22, R.drawable.a23, R.drawable.a24, R.drawable.a25, R.drawable.a26, R.drawable.a27, R.drawable.a28, R.drawable.a30, R.drawable.a31, R.drawable.a32, R.drawable.a33, R.drawable.a34, R.drawable.a35, R.drawable.a36, R.drawable.a37, R.drawable.a38, R.drawable.a39, R.drawable.a4, R.drawable.a40, R.drawable.a41, R.drawable.a42, R.drawable.a43, R.drawable.a5, R.drawable.a6, R.drawable.a7, R.drawable.a8, R.drawable.a9, R.drawable.aa9 }; // Constructor public ImageAdapter(Context c) { mContext = c; } @Override public int getCount() { return mThumbIds.length; } @Override public Object getItem(int position) { return mThumbIds[position]; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); if (convertView == null) { imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(250, 300)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(4, 4, 4, 4); } else { imageView = (ImageView) convertView; } imageView.setImageResource(mThumbIds[position]); return imageView; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload