线程退出时未捕获异常(group = 0xb2a18ba8)

时间:2014-08-04 10:45:59

标签: java android android-intent

我试图通过单击textview字母 t2 来进入下一页。我的意图是正确的,但我收到了错误,

线程退出时未捕获异常(组= 0xb2a18ba8)然后致命异常:主 java.lang.RuntimeException:无法启动activitycomponent信息(意图location)java.lang.NullPointerException “并强制关闭应用程序。请告诉我它是什么。

MainActivity.java

 package com.sedio.newsedio;

    @SuppressLint({ "NewApi", "ShowToast" })
    public class MainActivity extends ActionBarActivity {

        ImageView fliq_Logo;
        Button btn_Login,facebook_login,twiit_login;
        TextView t1;
        TextView t2;

        VideoView vd;
        Uri uri;
        //public static final String PREFS_NAME = "LoginPrefs";  
        private ConnectionDetector cd;
        AlertDialogManager alert = new AlertDialogManager();
        private URL Login_Url;
        private String login_inputline;
        private JSONArray login_jsonarray;
        private JSONObject login_jsonobj;
        private String login_status;
        private String User_id;
        private String accesskey;
        private String accesstoken;
        private String geteee;
        private String getfbid;
        private String getfbtkn;
        private String gettusr;
        private String gettkey;
        private String getfttkn;
        private String suuserid;
        static String TWITTER_CONSUMER_KEY = "************"; 
        static String TWITTER_CONSUMER_SECRET = "**********";
        String val="false";
        private static SocialAuthAdapter adapter;
        Profile profileMap;
        List photosList;

        // Android Components
        ListView listview;
        AlertDialog dialog;
        TextView title;
        ProgressDialog mDialog;

        // Variables
        boolean status;
        public static String providerName;
        public static int pos;
        public static Bitmap bitmap;
        Context context = this;

        String LiveUrl="http://demo.cogzidel.com/sedio/";
        // Preference Constants
        static String PREFERENCE_NAME = "twitter_oauth";
        static final String PREF_KEY_OAUTH_TOKEN = "oauth_token";
        static final String PREF_KEY_OAUTH_SECRET = "oauth_token_secret";
        static final String PREF_KEY_TWITTER_LOGIN = "isTwitterLogedIn";

        static final String TWITTER_CALLBACK_URL = "http://cloudcat.meliosystems.com/";

        // Twitter oauth urls
        static final String URL_TWITTER_AUTH = "auth_url";
        static final String URL_TWITTER_OAUTH_VERIFIER = "oauth_verifier";
        static final String URL_TWITTER_OAUTH_TOKEN = "oauth_token";
        public static String twitter_token, twitter_secret;

            public static final String PREFS_NAME = "MyPrefsFile";

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            adapter = new SocialAuthAdapter(new ResponseListener());
              if( Build.VERSION.SDK_INT >= 9){
                    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
                    StrictMode.setThreadPolicy(policy);
             }

              SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
             Editor editor = sharedPreferences.edit();
             editor.putString("liveurl", LiveUrl);  
             editor.putString("twi_log", val);                   
             editor.commit();
            String restoredText = sharedPreferences.getString("liveurl", null);

             System.out.println("Liveurl value--->"+restoredText);

                fliq_Logo=(ImageView) findViewById(R.id.logo_img);
                btn_Login=(Button) findViewById(R.id.login_newBtn);
                twiit_login=(Button) findViewById(R.id.Button01);

                t1=(TextView)findViewById(R.id.textView1);
                t2=(TextView)findViewById(R.id.textView2);  
                facebook_login=(Button)findViewById(R.id.button1);


                vd = (VideoView) findViewById(R.id.VideoView);
                 uri = Uri.parse("android.resource://"+getPackageName() + "/"+R.raw.spll);
                new MediaController(this);

                vd.setVideoURI(uri);                 
                vd.setOnPreparedListener (new OnPreparedListener() {                  
                    public void onPrepared(MediaPlayer mp) {
                        vd.start();
                        mp.setLooping(true);

                    }
                });


             getApplicationContext().getSharedPreferences("MyPref", 0);


                cd = new ConnectionDetector(getApplicationContext());

                // Check if Internet present
                if (!cd.isConnectingToInternet()) {
                    // Internet Connection is not present
                    alert.showAlertDialog(MainActivity.this, "Internet Connection Error",
                            "Please connect to working Internet connection", false);
                    // stop executing code by return
                    return;
                }

                twiit_login.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        twi_log();

               Intent i = new Intent(MainActivity.this, Twitter_Login.class);
                Bundle bndlanimation =ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.trans_left_in,R.anim.trans_left_out).toBundle();
                startActivity(i, bndlanimation);

                        //loginToTwitter();                              
                    }
                });

          //---- SharedPreferences email

                SharedPreferences settings = getSharedPreferences(SignIn.PREFS_NAME,1);
                    //Get "hasLoggedIn" value. If the value doesn't exist yet false is returned
                    boolean trLoggedIn = settings.getBoolean("trLoggedIn", false);              
                    String PREF_KEY = settings.getString("euser", geteee);                
                    String fbu_id = settings.getString("fuser", getfbid);
                    String fb_tkn = settings.getString("ftkn", getfbtkn);                
                    String tr_id = settings.getString("tuser", gettusr);
                    String tr_key = settings.getString("tacceskey", gettkey);
                    String tr_tkn = settings.getString("taccestkn", getfttkn);
                    String su_user = settings.getString("sinuser", suuserid); 

                    if(fb_tkn != null)
                    {
                        //Go directly to Sedio_main activity
                        Intent i = new Intent(MainActivity.this, Sedio_main.class);
                        i.putExtra("userid", fbu_id);
                        i.putExtra("fb_token", fb_tkn);
                        Bundle bndlanimation =ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.trans_left_in,R.anim.trans_left_out).toBundle();
                        startActivity(i, bndlanimation);

                    }

                    if(PREF_KEY != null)
                    {
                        //Go directly to Sedio_main activity
                        Intent i = new Intent(MainActivity.this, Sedio_main.class);
                        i.putExtra("userid", PREF_KEY);
                        Bundle bndlanimation =ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.trans_left_in,R.anim.trans_left_out).toBundle();
                        startActivity(i, bndlanimation);

                    }

                    if(trLoggedIn)
                    {
                           Intent Intent_imageview = new Intent(MainActivity.this, Sedio_main.class);
                           Intent_imageview.putExtra("userid", tr_id);
                           Intent_imageview.putExtra("accesskey", tr_key);
                           Intent_imageview.putExtra("accesstoken", tr_tkn);
                           startActivity(Intent_imageview);
                           finish();

                    }

                    if(su_user != null)
                    {
                        //Go directly to Sedio_main activity
                        Intent i = new Intent(MainActivity.this, Sedio_main.class);
                        i.putExtra("userid", su_user);
                        Bundle bndlanimation =ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.trans_left_in,R.anim.trans_left_out).toBundle();
                        startActivity(i, bndlanimation);

                    }
                facebook_login.setOnClickListener(new OnClickListener() {  //fb login

                    public void onClick(View v) {

                        Intent i=new Intent(MainActivity.this,FbLoader.class);
                        startActivity(i);                                  
                    }
                });

                btn_Login.setOnClickListener(new OnClickListener() {  //SignUp

                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                        Intent i = new Intent(MainActivity.this, SignUp.class);
                        Bundle bndlanimation =ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.trans_left_in,R.anim.trans_left_out).toBundle();
                        startActivity(i, bndlanimation);           

                    }
                });

                t2.setOnClickListener(new OnClickListener() {   // SignIn 

                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                        Intent i = new Intent(MainActivity.this, SignIn.class);
                        Bundle bndlanimation =ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.trans_left_in,R.anim.trans_left_out).toBundle();
                        startActivity(i, bndlanimation);                               

                    }
                });        
            }
        public void twi_log(){
             val="true";
             SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
             Editor editor = sharedPreferences.edit();
             editor.putString("twi_log", val);                                   
             editor.commit();
        }

        private void mani(String s12, String g2,String key1,String secret12,String sqw) {
            // TODO Auto-generated method stub

            BufferedReader login_reader;    
            String str_login="";

            try{  
                Login_Url       = new URL("http://demo.cogzidel.com/sedio/mobile/tlogin?user_id="+g2+"&screen_name="+s12+"&twitter_access_key="+key1+"&twitter_access_secret="+secret12+"&profile_image="+sqw);
                System.out.println("image url-------->" + Login_Url);

                System.out.println("image url-------->1");
                login_reader = new BufferedReader(new InputStreamReader(Login_Url.openStream()));
                System.out.println("image url-------->2");
                while ((login_inputline = login_reader.readLine())!= null)
                {
                     System.out.println("image url-------->3");
                    str_login += login_inputline;

                }
            System.out.print("login"+str_login);

                    login_jsonarray = new JSONArray(str_login);

                {
                    int i1=0;    
                     login_jsonobj = login_jsonarray.getJSONObject(i1);
                     login_status = login_jsonobj.getString("status");
                     User_id = login_jsonobj.getString("id");

                }
                System.out.println("json value ---------->"+login_status+User_id+accesskey+accesstoken);

                }  
            catch(MalformedURLException e){

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

             if(User_id != null)
             {

                     loadSavedPreferences();
                    Intent Intent_imageview = new Intent(MainActivity.this, Sedio_main.class);
                    Intent_imageview.putExtra("userid", User_id);
                    Intent_imageview.putExtra("accesskey", key1);
                    Intent_imageview.putExtra("accesstoken", secret12);
                    startActivity(Intent_imageview);
                    finish();

             }

             else{

                 Toast.makeText(getApplicationContext(),"Server Down", Toast.LENGTH_LONG).show();  

             }
        } 
            protected void onResume() {
            super.onResume();
        }
         private void loadSavedPreferences() {  
             //User has successfully logged in, save this information
             // We need an Editor object to make preference changes.

             SharedPreferences settings = getSharedPreferences(SignIn.PREFS_NAME, 0);
             SharedPreferences.Editor editor = settings.edit();

             //Set "hasLoggedIn" to true
             editor.putBoolean("trLoggedIn", true);

             editor.putString ("tuser", User_id);
             editor.putString ("tacceskey", accesskey);
             editor.putString ("taccestkn", accesstoken);
             // Commit the edits!
             editor.commit();

            }     
         //---------- Twitter login functionality----------->>>>>   
            public static SocialAuthAdapter getSocialAuthAdapter() {
                return adapter;
            }

            // To receive the response after authentication
            private final class ResponseListener implements DialogListener {

                @Override
                public void onComplete(Bundle values) {

                    Log.d("Custom-UI", "Successful");

                    // Changing Sign In Text to Sign Out               
                    // Get the provider
                    providerName = values.getString(SocialAuthAdapter.PROVIDER);

                    Log.d("Custom-UI", "providername = " + providerName);

                    Toast.makeText(MainActivity.this, providerName + " connected", Toast.LENGTH_SHORT).show();
                    Log.i("get profile ", "before");
                    adapter.getUserProfileAsync(new ProfileDataListener());
                    Log.i("get profile ", "after");
                    int res = getResources().getIdentifier(providerName + "_array", "array", MainActivity.this.getPackageName());
                    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                    builder.setTitle("Select Options");
                    builder.setCancelable(true);
                    builder.setIcon(android.R.drawable.ic_menu_more);
                    mDialog = new ProgressDialog(MainActivity.this);
                    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                    mDialog.setMessage("Loading...");
                    builder.setSingleChoiceItems(new DialogAdapter(MainActivity.this, R.layout.provider_options, getResources()
                            .getStringArray(res)), 0, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {
                            Log.i("item", ""+item);                         
                            dialog.dismiss();
                        }
                    });
                    dialog = builder.create();
                    //dialog.show();
                }
                @Override
                public void onError(SocialAuthError error) {
                    Log.d("Custom-UI", "Error");
                    error.printStackTrace();
                }
                @Override
                public void onCancel() {
                    Log.d("Custom-UI", "Cancelled");
                }
                @Override
                public void onBack() {
                    Log.d("Custom-UI", "Dialog Closed by pressing Back Key");
                }
            }
            // To receive the profile response after authentication
            private final class ProfileDataListener implements SocialAuthListener {

                @Override
                public void onExecute(String provider, Profile t) {

                    Log.d("Custom-UI", "Receiving Data");
                    mDialog.dismiss();
                    Profile profileMap = t;
                    //loadSavedPreferences();
                    String token=adapter.getCurrentProvider().getAccessGrant().getSecret();
                    System.out.println("Seceret value is--------------->"+token);
                    String key=adapter.getCurrentProvider().getAccessGrant().getKey();
                    System.out.println("key is----------->"+ key);
                    String []part=key.split("-");
                    String part1=part[0];
                    String part2=part[1].toString();
                    System.out.println("after split");
                    System.out.println("userid" + part1);
                    System.out.println("secret" + part2);
                    String id=profileMap.getValidatedId();
                    profileMap.getEmail();
                    String screen=profileMap.getFullName();
                    String sqw=profileMap.getProfileImageURL().toString();
                    System.out.println("screen---->" + screen);
                    System.out.println("id------->" + id);
                    System.out.println("secret---->" + token);
                    //System.out.println("image----->" + img);
                    mani(screen,id,part2,token,sqw);
                 }
                @Override
                public void onError(SocialAuthError e) {

                }
            }

            // To receive the profile response after authentication

            public class DialogAdapter extends BaseAdapter {
                // Android Components
                private final LayoutInflater mInflater;
                private final Context ctx;
                String[] drawables;
                String[] options;

                public DialogAdapter(Context context, int textViewResourceId, String[] providers) {
                    // Cache the LayoutInflate to avoid asking for a new one each time.
                    ctx = context;
                    mInflater = LayoutInflater.from(ctx);
                    options = providers;
                }

                @Override
                public int getCount() {
                    return options.length;
                }

                @Override
                public Object getItem(int position) {
                    return position;
                }

                @Override
                public long getItemId(int position) {
                    return position;
                }


                @Override
                public View getView(final int position, View convertView, ViewGroup parent) {
                    // A ViewHolder keeps references to children views to avoid
                    // unneccessary
                    // calls to findViewById() on each row.
                    ViewHolder holder;

                    // When convertView is not null, we can reuse it directly, there is no need to reinflate it. We only inflate a new View when the convertView supplied by ListView is null.

                    if (convertView == null) {
                        convertView = mInflater.inflate(R.layout.provider_options, null);

                        // Creates a ViewHolder and store references to the two children views we want to bind data to.
                        holder = new ViewHolder();
                        holder.text = (TextView) convertView.findViewById(R.id.providerText);
                        holder.icon = (ImageView) convertView.findViewById(R.id.provider);

                        convertView.setTag(holder);
                    } else {
                        // Get the ViewHolder back to get fast access to the TextView and the ImageView.
                        holder = (ViewHolder) convertView.getTag();
                    }

                    return convertView;
                }

                class ViewHolder {
                    TextView text;
                    ImageView icon;
                }
            }

    //-------End twitter function----->        

            @Override
            public void onBackPressed() {
                Log.d("Custom-UI", "Dialog Closed by pressing Back Key");

                System.exit(0);
                finish();
            }
    } 

这是我的 登入。java 文件 这是我的logcat

任何人都可以帮我解决这个问题吗?

0 个答案:

没有答案