Note that there are some explanatory texts on larger screens.

plurals
  1. POCamera intent not running
    primarykey
    data
    text
    <p>My camera activity is not working:</p> <p>I launch it from listActivity. I have another three activities from the list activity but camera activity/intent <code>force closes</code>.</p> <hr> <h2>Camera.java</h2> <pre><code> package com.alpha.beta; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; public class Camera extends Activity implements View.OnClickListener { ImageView Image; ImageView setWall; ImageButton TakePic; Bitmap bmap; Intent i; final static int cameraData = 0; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.camera); vars(); } private void vars() { // TODO Auto-generated method stub Image = (ImageView) findViewById(R.id.ivReturnPic); setWall = (ImageView) findViewById(R.id.bSetWallpaper); TakePic = (ImageButton) findViewById(R.id.iBTakePic); setWall.setOnClickListener(this); TakePic.setOnClickListener(this); } public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.iBTakePic: try { getApplicationContext().setWallpaper(bmap); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; case R.id.bSetWallpaper: i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(i, cameraData); break; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { Bundle extras = data.getExtras(); bmap = (Bitmap) extras.get("data"); Image.setImageBitmap(bmap); } } } </code></pre> <hr> <h2>Logcat</h2> <pre><code> 12-02 20:44:11.229: W/dalvikvm(6322): threadid=1: thread exiting with uncaught exception (group=0x40018578) 12-02 20:44:11.229: E/AndroidRuntime(6322): FATAL EXCEPTION: main 12-02 20:44:11.229: E/AndroidRuntime(6322): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alpha.beta/com.alpha.beta.Camera}: java.lang.ClassCastException: android.widget.Button 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.os.Handler.dispatchMessage(Handler.java:99) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.os.Looper.loop(Looper.java:130) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.app.ActivityThread.main(ActivityThread.java:3687) 12-02 20:44:11.229: E/AndroidRuntime(6322): at java.lang.reflect.Method.invokeNative(Native Method) 12-02 20:44:11.229: E/AndroidRuntime(6322): at java.lang.reflect.Method.invoke(Method.java:507) 12-02 20:44:11.229: E/AndroidRuntime(6322): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 12-02 20:44:11.229: E/AndroidRuntime(6322): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 12-02 20:44:11.229: E/AndroidRuntime(6322): at dalvik.system.NativeStart.main(Native Method) 12-02 20:44:11.229: E/AndroidRuntime(6322): Caused by: java.lang.ClassCastException: android.widget.Button 12-02 20:44:11.229: E/AndroidRuntime(6322): at com.alpha.beta.Camera.vars(Camera.java:34) 12-02 20:44:11.229: E/AndroidRuntime(6322): at com.alpha.beta.Camera.onCreate(Camera.java:27) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 12-02 20:44:11.229: E/AndroidRuntime(6322): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) </code></pre> <h2> 12-02 20:44:11.229: E/AndroidRuntime(6322): ... 11 more</h2> <h2>Manifest File</h2> <pre><code> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.alpha.beta" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /&gt; &lt;uses-permission android:name="android.permission.SET_WALLPAPER" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".Splash" android:label="@string/title_activity_app" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Menu" android:label="@string/title_activity_app" &gt; &lt;action android:name="com.alpha.beta.Menu" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/activity&gt; &lt;activity android:name=".App" android:label="@string/title_activity_app" &gt; &lt;/activity&gt; &lt;activity android:name=".TextPlay" android:label="@string/title_activity_app" &gt; &lt;/activity&gt; &lt;activity android:name=".Email" android:label="@string/title_activity_app" &gt; &lt;/activity&gt; &lt;activity android:name=".Camera" android:label="@string/title_activity_app" &gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
    singulars
    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