I have created an android application but it is not running properly. I don't know why it always stops at this line in the console.
[2012年03月29日 13:23:00 - AndroidBitmap] Starting activity com.example.Android.AndroidBitmapActivity on device emulator-5554
My program is as follows, which is code for the rotation of a bitmap package com.example.Android;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.Spinner;
public class AndroidBitmapActivity extends Activity {
private final String imageInSD = "/sdcard/er.PNG";
ImageView myImageView;
Spinner spinnerScale;
SeekBar seekbarRotate;
private static final String[] strScale
= {"0.2x", "0.5x", "1.0x", "2.0x", "5.0x"};
private static final Float[] floatScale
= {0.2F, 0.5F, 1F, 2F, 5F};
private final int defaultSpinnerScaleSelection = 2;
private ArrayAdapter<String> adapterScale;
private float curScale = 1F;
private float curRotate = 0F;
Bitmap bitmap;
int bmpWidth, bmpHeight;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myImageView = (ImageView)findViewById(R.id.imageview);
spinnerScale = (Spinner)findViewById(R.id.scale);
seekbarRotate = (SeekBar)findViewById(R.id.rotate);
adapterScale = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, strScale);
adapterScale.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerScale.setAdapter(adapterScale);
spinnerScale.setSelection(defaultSpinnerScaleSelection);
curScale = floatScale[defaultSpinnerScaleSelection];
bitmap = BitmapFactory.decodeFile(imageInSD);
bmpWidth = bitmap.getWidth();
bmpHeight = bitmap.getHeight();
drawMatrix();
spinnerScale.setOnItemSelectedListener(spinnerScaleOnItemSelectedListener);
seekbarRotate.setOnSeekBarChangeListener(seekbarRotateSeekBarChangeListener);
}
private void drawMatrix(){
Matrix matrix = new Matrix();
matrix.postScale(curScale, curScale);
matrix.postRotate(curRotate);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true);
myImageView.setImageBitmap(resizedBitmap);
}
private SeekBar.OnSeekBarChangeListener seekbarRotateSeekBarChangeListener
= new SeekBar.OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
curRotate = (float)progress;
drawMatrix();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}};
private Spinner.OnItemSelectedListener spinnerScaleOnItemSelectedListener
= new Spinner.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
curScale = floatScale[arg2];
drawMatrix();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
spinnerScale.setSelection(defaultSpinnerScaleSelection);
curScale = floatScale[defaultSpinnerScaleSelection];
}};
}
my manifest file is as follow
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidBitmapActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
my console is showing following thing
[2012年03月29日 13:23:00 - AndroidBitmap] Android Launch!
[2012年03月29日 13:23:00 - AndroidBitmap] adb is running normally.
[2012年03月29日 13:23:00 - AndroidBitmap] Performing com.example.Android.AndroidBitmapActivity activity launch
[2012年03月29日 13:23:00 - AndroidBitmap] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'A2.2'
[2012年03月29日 13:23:00 - AndroidBitmap] WARNING: Unknown device API version!
[2012年03月29日 13:23:00 - AndroidBitmap] Uploading AndroidBitmap.apk onto device 'emulator-5554'
[2012年03月29日 13:23:00 - AndroidBitmap] Installing AndroidBitmap.apk...
[2012年03月29日 13:23:00 - AndroidBitmap] Success!
[2012年03月29日 13:23:00 - AndroidBitmap] Starting activity com.example.Android.AndroidBitmapActivity on device emulator-5554
3 Answers 3
At a guess I would say you haven't declared the AndroidBitmapActivity in your AndroidManifest.xml file, but I think it would be helpful if you posted more of the stacktrace (and possibly the Manifest file too).
8 Comments
Are you trying to access the SD Card?
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1 Comment
it should have a problem with your SD card (if not created then create it first )and i think you haven't a image "er.PNG" in your SD card(if same name image is not in your sd card it will never run) first check out it properly and let try...