Soru & Cevap

The apllication has stopped unexpectedly.

12.07.2014 - 06:57

öncelikle yapmak istediğim sayfalar arası geçiş yaparak mainpoint sayfasındaki butona basıp barkod okumamı sağlayan read sayfasına gitmek istiyorum. main pointe gitmek tuşa basınca uygulamam kapanıyor acaba sorun nedir

-main activityim burda

package com.example.yeni;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

 

public class MainActivity extends ActionBarActivity {
Button ileri;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        ileri = (Button)findViewById(R.id.btPuan);
        ileri.setOnClickListener(new OnClickListener() {
        
            @Override
            public void onClick(View view) {
                // TODO Auto-generated method stub
                Intent i = new Intent(MainActivity.this,MainPoint.class);
                startActivity(i);            }
        });
        final String[] KartK = { "Kayıtlı Kart Seciniz" ,"Seçmeyiniz..."};
              Spinner spinner = (Spinner) findViewById(R.id.spCard);
        final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                        android.R.layout.simple_list_item_checked, android.R.id.text1,
                        KartK);
        spinner.setAdapter(adapter);
        
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}--------mainpoint adındaki oluşturduğum clasım bu

package com.example.yeni;

import net.sourceforge.zbar.Config;
import net.sourceforge.zbar.Image;
import net.sourceforge.zbar.ImageScanner;
import net.sourceforge.zbar.Symbol;
import net.sourceforge.zbar.SymbolSet;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;

public class MainPoint extends Activity{
    
    Button geri,ilerii;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.example.yeni.R.layout.loadpointt);
        
        geri=(Button)findViewById(R.id.button1);
        geri.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View view) {
                 //TODO Auto-generated method stub
            finish();}});
        ilerii=(Button)findViewById(R.id.button2);
        ilerii.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent p = new Intent(MainPoint.this,Read.class);
                startActivity(p);    
            }
        });---------------read adındaki clasımda bu 

package com.example.yeni;

import net.sourceforge.zbar.Config;
import net.sourceforge.zbar.Image;
import net.sourceforge.zbar.ImageScanner;
import net.sourceforge.zbar.Symbol;
import net.sourceforge.zbar.SymbolSet;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

public class Read extends Activity{
    private Camera mCamera;
    private CameraPreview mPreview;
    private Handler autoFocusHandler;

    TextView scanText;
    Button scanButton;

    ImageScanner scanner;

    private boolean barcodeScanned = false;
    private boolean previewing = true;
    static {
        System.loadLibrary("iconv");
    } 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.barcode);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        autoFocusHandler = new Handler();
        mCamera = getCameraInstance();

        /* Instance barcode scanner */
        scanner = new ImageScanner();
        scanner.setConfig(0, Config.X_DENSITY, 3);
        scanner.setConfig(0, Config.Y_DENSITY, 3);

        mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
        FrameLayout preview = (FrameLayout)findViewById(R.id.cameraPreview);
        preview.addView(mPreview);

        scanText = (TextView)findViewById(R.id.scanText);

    }
    public void onPause() {
        super.onPause();
        releaseCamera();
    }

    /** A safe way to get an instance of the Camera object. */
    public static Camera getCameraInstance(){
        Camera c = null;
        try {
            c = Camera.open();
        } catch (Exception e){
        }
        return c;
    }

    private void releaseCamera() {
        if (mCamera != null) {
            previewing = false;
            mCamera.setPreviewCallback(null);
            mCamera.release();
            mCamera = null;
        }
    }

    private Runnable doAutoFocus = new Runnable() {
            public void run() {
                if (previewing)
                    mCamera.autoFocus(autoFocusCB);
            }
        };

    PreviewCallback previewCb = new PreviewCallback() {
            public void onPreviewFrame(byte[] data, Camera camera) {
                Camera.Parameters parameters = camera.getParameters();
                Size size = parameters.getPreviewSize();

                Image barcode = new Image(size.width, size.height, "Y800");
                barcode.setData(data);

                int result = scanner.scanImage(barcode);
                
                if (result != 0) {
                    
                    SymbolSet syms = scanner.getResults();
                    for (Symbol sym : syms) {
                        scanText.setText("Barkod Sonucu: " + sym.getData());
                        scanText.setTextColor(Color.parseColor("#00AF03"));
                        barcodeScanned = true;
                        releaseCamera();
                        Intent intent = new Intent();
                        intent.putExtra("SCAN_RESULT", sym.getData());
                        setResult(RESULT_OK, intent);
                    }
                }
            }
        };

    // Mimic continuous auto-focusing
    AutoFocusCallback autoFocusCB = new AutoFocusCallback() {
            public void onAutoFocus(boolean success, Camera camera) {
                autoFocusHandler.postDelayed(doAutoFocus, 1000);
            }
        };

}-------- logcat te ise böyle hatalar çıkıyo

07-12 18:54:01.807: E/AndroidRuntime(560): FATAL EXCEPTION: main
07-12 18:54:01.807: E/AndroidRuntime(560): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yeni/com.example.yeni.MainPoint}: java.lang.ClassCastException: android.widget.EditText
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.os.Looper.loop(Looper.java:123)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-12 18:54:01.807: E/AndroidRuntime(560):     at java.lang.reflect.Method.invokeNative(Native Method)
07-12 18:54:01.807: E/AndroidRuntime(560):     at java.lang.reflect.Method.invoke(Method.java:521)
07-12 18:54:01.807: E/AndroidRuntime(560):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-12 18:54:01.807: E/AndroidRuntime(560):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-12 18:54:01.807: E/AndroidRuntime(560):     at dalvik.system.NativeStart.main(Native Method)
07-12 18:54:01.807: E/AndroidRuntime(560): Caused by: java.lang.ClassCastException: android.widget.EditText
07-12 18:54:01.807: E/AndroidRuntime(560):     at com.example.yeni.MainPoint.onCreate(MainPoint.java:41)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-12 18:54:01.807: E/AndroidRuntime(560):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-12 18:54:01.807: E/AndroidRuntime(560):     ... 11 more

 

            
       
        
    }
    
   
}

 

4 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user emre190745
emre190745
12.07.2014 - 07:11

sorunu buldum xml dosyamda hatalı bi kod vardı düzelttim