0

So, I wanted to create a social networking page for the user where they would have on screen button options to bring them to their social networking option of choice, and on this screen I decided to include a reference to the camera, but when I include the camera in my Java code my app won't launch, when I comment it out, it will launch, am I missing something?

Here's my Java code:

    package com.example.nxtremotecontroler;

    import android.app.Activity;
    import android.content.ComponentName;
    import android.content.ContentValues;
    import android.content.Intent;
    import android.content.pm.ActivityInfo;
    import android.net.Uri;
    import android.os.Bundle;
    import android.provider.MediaStore;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.ImageView;

    public class socialnetworking extends Activity {
Button email, options;
ImageView instagram, facebook, twitter, camerabtn;

@Override
public void onCreate(Bundle SavedInstanceState) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    super.onCreate(SavedInstanceState);
    setContentView(R.layout.socialnetworking);

    instagram = (ImageView) findViewById(R.id.instagrambtn);
    facebook = (ImageView) findViewById(R.id.facebookbtn);
    email = (Button) findViewById(R.id.emailbtn);
    twitter = (ImageView) findViewById(R.id.twitterbtn);
    options = (Button) findViewById(R.id.Options);

    email.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent emailIntent = new Intent(
                    android.content.Intent.ACTION_SEND);
            emailIntent.setType("text/plain");
            startActivity(emailIntent);
        }
    });

    facebook.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            try {

                Intent intent = new Intent(Intent.ACTION_VIEW, Uri
                        .parse("fb://?ref=tn_tnmn"));
                startActivity(intent);

            } catch (Exception e) {

                startActivity(new Intent(Intent.ACTION_VIEW, Uri
                        .parse("http://www.facebook.com/?ref=tn_tnmn")));
            }
        }
    });

    twitter.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v){
            String url = "https://twitter.com/intent/tweet?source=webclient&text=TWEET+THIS!";
            Intent twitterIntent = new Intent(android.content.Intent.ACTION_VIEW);
            twitterIntent.setData(Uri.parse(url));
            startActivity(twitterIntent);
        }
    });

    instagram.setOnClickListener(new OnClickListener() {            
        @Override
        public void onClick(View v) {
            String url = "https://instagram.com/accounts/login/";
            Intent instagramIntent = new Intent(android.content.Intent.ACTION_VIEW);
            instagramIntent.setData(Uri.parse(url));
            startActivity(instagramIntent);
        }
    });

    options.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v){
            Intent othersIntent = new Intent(android.content.Intent.ACTION_VIEW);
            othersIntent.setType("text/plain");
            startActivity(Intent.createChooser(othersIntent, "Choose one"));
        }
    });

    camerabtn.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v){
            Intent intent = new Intent("android.intent.action.MAIN");
               intent.setComponent(ComponentName.unflattenFromString("com.google.android.camera/com.android.camera.Camera"));
               intent.addCategory("android.intent.category.LAUNCHER");
               startActivity(intent);
        }
    });
}
    }

if my XML or LogCat log is needed just let me know

1 Answers1

0

You forgot to do something like this:

camerabtn = (ImageView) findViewById(R.id.camerabtn);
zbr
  • 6,860
  • 4
  • 31
  • 43