Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6532067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:57:17+00:00 2026-05-25T09:57:17+00:00

Here’s my current code: public class MallMapActivity extends Activity { private final static String

  • 0

Here’s my current code:

public class MallMapActivity extends Activity {
    private final static String tag = "MallMapActivity";
    private ImageView iv;
    private final static String FLOOR = "F";
    private final String storagePath = Environment.getExternalStorageDirectory() + "/appdata23";
    private final String localMapsPath = storagePath + "/localMaps";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        iv = (ImageView)findViewById(R.id.imageview);
        //iv.setScaleType(ScaleType.FIT_XY);

        final LinearLayout levelLayout = (LinearLayout) findViewById(R.id.level_layout);
        int levelSize = 8;
        for (int i = 0; i < levelSize; i++) {
            Button levelButton = new Button(this.getApplicationContext());
            if(i==0) {
                levelButton.setText(new StringBuffer((i+1)+"").append(FLOOR).append("(start)"));
            } else if (i==7) {
                levelButton.setText(new StringBuffer((i+1)+"").append(FLOOR).append("(end)"));
            } else {
                levelButton.setText(new StringBuffer((i+1)+"").append(FLOOR));
            }
            levelButton.setTag((i+1) + FLOOR);
            levelButton.setId(i);
            levelButton.setLayoutParams(
                    new RadioGroup.LayoutParams(0, RadioGroup.LayoutParams.WRAP_CONTENT, 1));
            levelButton.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View view) {
                    int childCount = levelLayout.getChildCount();
                    int viewId = view.getId();

                    for (int j = 0; j < childCount; j++) {
                        Button btn = (Button)levelLayout.getChildAt(j); 
                        if(viewId == j) 
                            btn.setTextColor(Color.BLUE);
                        else
                            btn.setTextColor(Color.BLACK);
                    }

                    //sample data
                    double currentPixelX = 169d;
                    double currentPixelY = 347d;
                    Log.i(tag, " currentPixelX:" + currentPixelX);
                    Log.i(tag, " currentPixelY:" + currentPixelY);

                    int circleSize = 20;
                    Paint currentPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                    currentPaint.setColor(Color.GREEN);
                    currentPaint.setAlpha(75);

                    String path = new StringBuffer(localMapsPath)
                        .append("/").append(view.getTag()).append(".png").toString();
                    File file = new File(path);
                    InputStream stream = null;
                    try {
                        stream = new FileInputStream(file);
                    } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    Bitmap mapBitmap = BitmapFactory.decodeStream(stream);

                    Canvas canvas = new Canvas(mapBitmap);
                    canvas.drawCircle(
                            Double.valueOf(currentPixelX).floatValue(), 
                            Double.valueOf(currentPixelY).floatValue(),
                            circleSize, currentPaint);

                    iv.setImageBitmap(mapBitmap);
                    iv.invalidate();

                }
            });

            levelLayout.addView(levelButton);
        }
        levelLayout.getChildAt(0).performClick();

    }

}

Here’s the error content:

ERROR/AndroidRuntime(8626): Uncaught handler: thread main exiting due
to uncaught exception ERROR/AndroidRuntime(8626):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.sample/com.sample.MallMapActivity}:
java.lang.IllegalStateException: Immutable bitmap passed to Canvas
*constructor* ERROR/AndroidRuntime(8626): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
ERROR/AndroidRuntime(8626): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
ERROR/AndroidRuntime(8626): at
android.app.ActivityThread.access$2200(ActivityThread.java:123)
ERROR/AndroidRuntime(8626): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
ERROR/AndroidRuntime(8626): at
android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(8626): at
android.os.Looper.loop(Looper.java:123) ERROR/AndroidRuntime(8626):
at android.app.ActivityThread.main(ActivityThread.java:4370)
ERROR/AndroidRuntime(8626): at
java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(8626): at
java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(8626): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(8626): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(8626): at
dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(8626): Caused by:
java.lang.IllegalStateException: Immutable bitmap passed to Canvas
*constructor* ERROR/AndroidRuntime(8626): at
android.graphics.Canvas.(Canvas.java:83)
ERROR/AndroidRuntime(8626): at
com.sample.MallMapActivity$1.onClick(MallMapActivity.java:110)
ERROR/AndroidRuntime(8626): at
android.view.View.performClick(View.java:2397)
ERROR/AndroidRuntime(8626): at
com.sample.MallMapActivity.onCreate(MallMapActivity.java:124)
ERROR/AndroidRuntime(8626): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
ERROR/AndroidRuntime(8626): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
ERROR/AndroidRuntime(8626): … 11 more ERROR/SemcCheckin(8626):
Get crash dump level : java.io.FileNotFoundException:
/data/semc-checkin/crashdump ERROR/SemcCheckin(1544): Get Crash Level
: java.io.FileNotFoundException: /data/semc-checkin/crashdump

UPDATE:

  1. mapBitmap.isMutable() is returning false value.
  2. to make it mutable i changed the code
Bitmap mapBitmap = BitmapFactory.decodeStream(stream);
Bitmap newMapBitmap = mapBitmap.copy(Bitmap.Config.ARGB_8888,

true);
Canvas canvas = new Canvas(newMapBitmap);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:57:17+00:00Added an answer on May 25, 2026 at 9:57 am

    make this change : you cant draw on immutable bitmap instead you can create one

      Bitmap mapBitmap = BitmapFactory.decodeStream(stream);
    //make a new mutable  bitmap 
    Bitmap map = createBitmap(mapBitmap.getWidth(), mapBitmap.getHeight(),mapBitmap.getConfig());
    //copy the pixel to it 
    int [] allpixels = new int [ mapBitmap.getHeight()*mapBitmap.getWidth()];
    
    mapBitmap.getPixels(allpixels, 0, mapBitmap.getWidth(), 0, 0, mapBitmap.getWidth(),mapBitmap.getHeight());
    
    map.setPixels(allpixels, 0, mapBitmap.getWidth(), 0, 0, mapBitmap.getWidth(), mapBitmap.getHeight());
    
    
                        Canvas canvas = new Canvas(map);
    

    then start drawing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's the code: #include <string> class Config { public: static const std::string asdf =
Here is my object constructor static class Edge { int source; // source node
Here's my code $string = preg_replace(/rad\:([0-9]+)px\;\s+\/\*\sALT\[(.+)\*\/|rad\:([0-9]+)px\;/,($2?$2:$1),$string); Basically, in the regex I've got a pipe
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here's my code: delegate.h #import <UIKit/UIKit.h> @class _4_Control_FunViewController; @interface _4_Control_FunAppDelegate : NSObject <UIApplicationDelegate> {
Here is my code, which takes two version identifiers in the form 1, 5,
here is my php code..... <?php function nicetime($date) { if(empty($date)) { return No date
Here's the top of my usercontrol: <UserControl x:Class=MyApp.Common.Controls.Views.SimpleView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:Framework=http://www.memoryexpress.com/UIFramework mc:Ignorable=d
here a a piece of code that is supposed to loop over and over
Here is my code: PtyView *v = [[PtyView alloc] init]; [v sendData([charlieImputText stringValue])]; in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.