0

I have created a main screen to have 3 buttons. And one of them is to open another page that displays data from my database in a textview. It works perfectly on the emulator on my laptop but when I copy the files to my Nexus 7 that button crashes the application. All other buttons work fine.

here's the code, very basic:

viewFlare = (Button)findViewById(R.id.bViewFlare);

viewFlare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent openViewFlare = new Intent("com.example.project.SQLFLAREVIEW");
                startActivity(openViewFlare);
            }
        });

it calls this page:

public class SQLFlareView extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sqlflareview);

        TextView textView = (TextView) findViewById(R.id.tvSQLFlareinfo);

        Calms info = new Calms(this);
        info.open();
        //System.out.print("THIS IS THIS OPEN");
        String data = info.getFlareData();
        //System.out.print("ABOUT TO CLOSE");
        info.close();
        textView.setText(data);

    }
}

If anyone would have any ideas I would be very appreciative, I have banged my head about this problem for a while.

Thanks in advance

user2026576
  • 61
  • 2
  • 2
  • 6
  • 6
    Post the logcat from the crash. – Khantahr Feb 05 '13 at 18:43
  • Could you post a stacktrace ? You can get it form logcat – lokoko Feb 05 '13 at 18:48
  • sorry guys this is the first time I have tried to use this device, as I'm sure you have guessed :/ how would I be able to get the logcat from the device? I can get logcat from the emulator through adb in the terminal on my laptop – user2026576 Feb 05 '13 at 19:37
  • sorry I have found how to debug the device.. The logs are this – user2026576 Feb 05 '13 at 20:20
  • E/AndroidRuntime( 7885): FATAL EXCEPTION: main E/AndroidRuntime( 7885): java.lang.RuntimeException: Unable to start activity C mponentInfo{com.example/com.example.SQLFlareView}: java.lang.NullPointerExcepti n E/AndroidRuntime( 7885): at android.app.ActivityThread.performLaunchActi ity(ActivityThread.java:2180) E/AndroidRuntime( 7885): at android.app.ActivityThread.handleLaunchActiv ty(ActivityThread.java:2230) E/AndroidRuntime( 7885): at android.app.ActivityThread.access$600(Activi yThread.java:141) – user2026576 Feb 05 '13 at 20:26
  • Can you post your AndroidManifest.xml file? Invocation problems can usually be traced back to a bad entry in the manifest. – John O'Connor Feb 05 '13 at 20:33
  • Sorry again guys, the problem has been fixed, the R file had been messed around with. I cleaned the code in the device and used a new fresh build and everything works fine again. Thanks for all your help – user2026576 Feb 05 '13 at 21:22

1 Answers1

0

Change this:

Intent openViewFlare = new Intent("com.example.project.SQLFLAREVIEW");

To this:

Intent openViewFlare = new Intent(name_of_current_class.this, SQLFLAREVIEW.class");
bren
  • 3
  • 2