Guest User

Untitled

a guest
Jun 5th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.33 KB | None | 0 0
  1. Skip to content
  2. This repository
  3. Search
  4. Pull requests
  5. Issues
  6. Gist
  7.  @ahmetcuneydioglu
  8.  Unwatch 1
  9.   Star 0
  10.   Fork 0 ahmetcuneydioglu/AdaletPro
  11.  Code  Issues 0  Pull requests 0  Wiki  Pulse  Graphs  Settings
  12. Branch: master Find file Copy pathAdaletPro/app/src/main/java/adalet/quiz/pro/FbLogin.java
  13. 16fa72b  7 days ago
  14. @ahmetcuneydioglu ahmetcuneydioglu evde düzenleme yaptım
  15. 1 contributor
  16. RawBlameHistory     713 lines (568 sloc)  18.1 KB
  17. package adalet.quiz.pro;
  18.  
  19. import android.app.Activity;
  20. import android.app.AlertDialog;
  21. import android.app.ProgressDialog;
  22. import android.content.Context;
  23. import android.content.DialogInterface;
  24. import android.content.Intent;
  25. import android.content.IntentSender.SendIntentException;
  26. import android.content.SharedPreferences;
  27. import android.content.pm.PackageInfo;
  28. import android.content.pm.PackageManager;
  29. import android.content.pm.PackageManager.NameNotFoundException;
  30. import android.content.pm.Signature;
  31. import android.graphics.Typeface;
  32. import android.location.Address;
  33. import android.location.Geocoder;
  34. import android.os.AsyncTask;
  35. import android.os.Bundle;
  36. import android.os.StrictMode;
  37. import android.preference.PreferenceManager;
  38. import android.provider.Settings.Secure;
  39. import android.util.Base64;
  40. import android.util.Log;
  41. import android.view.Menu;
  42. import android.view.View;
  43. import android.view.View.OnClickListener;
  44. import android.widget.Button;
  45. import android.widget.TextView;
  46. import android.widget.Toast;
  47.  
  48. import com.facebook.CallbackManager;
  49. import com.facebook.FacebookCallback;
  50. import com.facebook.FacebookException;
  51. import com.facebook.FacebookSdk;
  52. import com.facebook.GraphRequest;
  53. import com.facebook.GraphResponse;
  54. import com.facebook.login.LoginResult;
  55. import com.facebook.login.widget.LoginButton;
  56. import com.google.android.gms.common.ConnectionResult;
  57. import com.google.android.gms.gcm.GoogleCloudMessaging;
  58.  
  59. import org.apache.http.HttpEntity;
  60. import org.apache.http.HttpResponse;
  61. import org.apache.http.NameValuePair;
  62. import org.apache.http.client.ClientProtocolException;
  63. import org.apache.http.client.HttpClient;
  64. import org.apache.http.client.entity.UrlEncodedFormEntity;
  65. import org.apache.http.client.methods.HttpPost;
  66. import org.apache.http.impl.client.DefaultHttpClient;
  67. import org.apache.http.message.BasicNameValuePair;
  68. import org.apache.http.protocol.HTTP;
  69. import org.apache.http.util.EntityUtils;
  70. import org.json.JSONException;
  71. import org.json.JSONObject;
  72.  
  73. import java.io.IOException;
  74. import java.io.UnsupportedEncodingException;
  75. import java.net.HttpURLConnection;
  76. import java.net.MalformedURLException;
  77. import java.net.URL;
  78. import java.security.MessageDigest;
  79. import java.security.NoSuchAlgorithmException;
  80. import java.util.ArrayList;
  81. import java.util.List;
  82. import java.util.Locale;
  83.  
  84. import adalet.quiz.pro.view.GoogleProgress;
  85.  
  86.  
  87. public class FbLogin extends Activity  {
  88.  
  89.  
  90.     private static final String TAG = "MainFragment";
  91.  
  92.     Typeface normal, bold;
  93.     TextView txtskip;
  94.     GoogleCloudMessaging gcm;
  95.     String regid, name, username, location, lastname, logintype, profileurl,
  96.             gender, city, country;
  97.     String PROJECT_NUMBER = DataManager.PROJECT_NUMBER;
  98.     private ProgressDialog progress;
  99.     String msg = "";
  100.     SharedPreferences prefs;
  101.     SessionManager session;
  102.     Button btnlogin, register;
  103.     // google+ login
  104.     private static final int RC_SIGN_IN = 0;
  105.     GPSTracker gps;
  106.     String strLatitude, strLongitude, xp;
  107.     private boolean mIntentInProgress;
  108.     private ConnectionResult mConnectionResult;
  109.     private boolean mSignInClicked;
  110.     private CallbackManager callbackManager;
  111.     Geocoder geocoder;
  112.     double longitude = 0, latitude = 0;
  113.     private String deviceid = "";
  114.     Button btnregister, btnemailsignin;
  115.     @Override
  116.     protected void onCreate(Bundle savedInstanceState) {
  117.         super.onCreate(savedInstanceState);
  118.         FacebookSdk.sdkInitialize(getApplicationContext());
  119.         setContentView(R.layout.activity_fb_login);
  120.  
  121.         normal = Typeface.createFromAsset(getAssets(), "normal.ttf");
  122.         bold = Typeface.createFromAsset(getAssets(), "bold.ttf");
  123.  
  124.  
  125.         session = new SessionManager(this);
  126.         callbackManager = CallbackManager.Factory.create();
  127.         if (!session.isLoggedIn()) {
  128.             callFacebookLogout(getApplicationContext());
  129.  
  130.  
  131.         }
  132.         deviceid = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
  133.  
  134.         geocoder = new Geocoder(this, Locale.getDefault());
  135.         gps = new GPSTracker(this);
  136.  
  137.         prefs = PreferenceManager.getDefaultSharedPreferences(this);
  138.         getRegId();
  139.  
  140.         getlocation();
  141.  
  142.         try {
  143.             PackageInfo info = getPackageManager().getPackageInfo(
  144.                     "adalet.quiz.pro", PackageManager.GET_SIGNATURES);
  145.             for (Signature signature : info.signatures) {
  146.                 MessageDigest md = MessageDigest.getInstance("SHA");
  147.                 md.update(signature.toByteArray());
  148.                 Log.d("KeyHash:",
  149.                         Base64.encodeToString(md.digest(), Base64.DEFAULT));
  150.             }
  151.         } catch (NameNotFoundException e) {
  152.  
  153.         } catch (NoSuchAlgorithmException e) {
  154.  
  155.         }
  156.  
  157.          btnregister = (Button) findViewById(R.id.btnregister);
  158.          
  159.        
  160.         btnemailsignin = (Button) findViewById(R.id.btnemailsignin);
  161.         LoginButton loginButton = (LoginButton) findViewById(R.id.loginButton);
  162.         loginButton.setReadPermissions("email");
  163.         loginButton.registerCallback(callbackManager,
  164.                 new FacebookCallback<LoginResult>() {
  165.                     @Override
  166.                     public void onSuccess(final LoginResult loginResult) {
  167.                         // App code
  168.                         System.out.println("Success---" + loginResult.getAccessToken());
  169.                         Toast.makeText(FbLogin.this, "Giriş Başarılı!", Toast.LENGTH_LONG).show();
  170.                         logintype = "2";
  171.                         GraphRequest request =    GraphRequest.newMeRequest(
  172.                                 loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
  173.                                     @Override
  174.                                     public void onCompleted(JSONObject json, GraphResponse response) {
  175.                                         if (response.getError() != null) {
  176.                                             // handle error
  177.                                             System.out.println("ERROR");
  178.                                         } else {
  179.                                             System.out.println("Success");
  180.                                             try {
  181.  
  182.                                                 String jsonresult = String.valueOf(json);
  183.                                                 System.out.println("JSON Result" + jsonresult);
  184.                                                 username = json.getString("id");
  185.                                                 name =json.getString("name");
  186.                                                 lastname = "";
  187.                                                 String firsturl = "http://graph.facebook.com/"+username+"/picture?type=large";
  188.                                                 profileurl = GetDirectURL(firsturl);
  189. //                                              email = json.getString("email");
  190. //                                              gender = json.getString("gender").toString();
  191.  
  192.                                                 logintype = "facebook";
  193.  
  194.                                                 new login().execute();
  195.  
  196. //                                              username = json.getString("id");
  197. //                                              password = json.getString("id");
  198. //                                              name = json.getString("name");
  199. //                                              email = json.getString("email");
  200. //
  201. //                                              login();
  202.                                             } catch (JSONException e) {
  203.                                                 System.out.println("here----" + e.getMessage());
  204.                                                 e.printStackTrace();
  205.                                             }
  206.                                         }
  207.                                     }
  208.  
  209.                                 });
  210.                         Bundle parameters = new Bundle();
  211.                         parameters.putString("fields", "id,name,email");
  212.                         request.setParameters(parameters);
  213.                         request.executeAsync();
  214. //                                executeAsync();
  215.  
  216.  
  217.  
  218.                     }
  219.                     @Override
  220.                     public void onCancel() {
  221.                         // App code
  222.                         System.out.println("onCancel");
  223.  
  224.                     }
  225.  
  226.                     @Override
  227.                     public void onError(FacebookException exception) {
  228.                         // App code
  229.                         System.out.println("exception--"+exception.toString());
  230.  
  231.                     }
  232.                 });
  233.  
  234.        
  235.         btnregister.setOnClickListener(new OnClickListener() {
  236.  
  237.             @Override
  238.             public void onClick(View v) {
  239.                 // TODO Auto-generated method stub
  240.  
  241.                 Intent i = new Intent(FbLogin.this, RegisterActivity.class);
  242.                 finish();
  243.                 startActivity(i);
  244.                 overridePendingTransition(0, 0);
  245.                
  246.             }
  247.         });
  248.        
  249.         btnemailsignin.setOnClickListener(new OnClickListener() {
  250.  
  251.             @Override
  252.             public void onClick(View v) {
  253.                 // TODO Auto-generated method stub
  254.  
  255.                 Intent i = new Intent(FbLogin.this, LoginActivity.class);
  256.                 finish();
  257.                 startActivity(i);
  258.                 overridePendingTransition(0, 0);
  259.             }
  260.         });
  261.        
  262.          btnemailsignin.setTypeface(bold);
  263.          btnregister.setTypeface(bold);
  264.  
  265.     }
  266.  
  267.     public static void callFacebookLogout(Context context) {
  268.  
  269. //      callFacebookLogout(context);
  270.  
  271.     }
  272.  
  273. //  private void signOutFromGplus() {
  274. //
  275. //      if (mGoogleApiClient.isConnected()) {
  276. //          Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
  277. //          mGoogleApiClient.disconnect();
  278. //          mGoogleApiClient.connect();
  279. //          Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
  280. //          Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient)
  281. //                  .setResultCallback(new ResultCallback<Status>() {
  282. //
  283. //                      @Override
  284. //                      public void onResult(Status arg0) {
  285. //                          // TODO Auto-generated method stub
  286. //                          mGoogleApiClient.disconnect();
  287. //                      }
  288. //
  289. //                  });
  290. //      }
  291. //      if (!mGoogleApiClient.isConnecting()) {
  292. //          mSignInClicked = false;
  293. //          return;
  294. //
  295. //      }
  296. //
  297. //
  298. //
  299. //  }
  300.  
  301. //  private void signInWithGplus() {
  302. //
  303. //      if (!mGoogleApiClient.isConnecting()) {
  304. //          mSignInClicked = true;
  305. //          resolveSignInError();
  306. //
  307. //      }
  308. //  }
  309.  
  310.     public void getlocation() {
  311.  
  312.         if (gps.canGetLocation()) {
  313.             try {
  314.                 if (gps.canGetLocation()) {
  315.                     Log.d("Your Location", "latitude:" + gps.getLatitude()
  316.                             + ", longitude: " + gps.getLongitude());
  317.                     latitude = gps.getLatitude();
  318.                     longitude = gps.getLongitude();
  319.                 }
  320.  
  321.                 if (latitude == 0.0 && longitude == 0.0) {
  322.                     city = "";
  323.                     country = "";
  324.                 } else {
  325.                     List<Address> addresses;
  326.                    
  327.                    
  328.                     addresses = geocoder
  329.                             .getFromLocation(latitude, longitude, 1);
  330.  
  331.                    
  332.                
  333.  
  334.                     city = "";
  335.                     country = "";
  336.  
  337.                 }
  338.  
  339.                 System.out.println("city----" + city);
  340.                 System.out.println("country----" + country);
  341.             } catch (IOException e) {
  342.                 // TODO Auto-generated catch block
  343.                 e.printStackTrace();
  344.             }
  345.         }
  346.  
  347.     }
  348.  
  349.     @Override
  350.     public boolean onCreateOptionsMenu(Menu menu) {
  351.         // Inflate the menu; this adds items to the action bar if it is present.
  352.  
  353.         return true;
  354.     }
  355.  
  356. //  private void getProfileInformation() {
  357. //      try {
  358. //          if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
  359. //              Person currentPerson = Plus.PeopleApi
  360. //                      .getCurrentPerson(mGoogleApiClient);
  361. //              String personName = currentPerson.getDisplayName();
  362. //              String personPhotoUrl = currentPerson.getImage().getUrl();
  363. //              String personGooglePlusProfile = currentPerson.getUrl();
  364. //              String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
  365. //              username = currentPerson.getId();
  366. //              name = currentPerson.getDisplayName();
  367. //              lastname = "";
  368. //              profileurl = currentPerson.getImage().getUrl();
  369. //              int sex = currentPerson.getGender();
  370. ////                city = currentPerson.getCurrentLocation();
  371. //
  372. //              System.out.println("sex---" + sex);
  373. //              System.out.println("city---" + city);
  374. //
  375. //              if(sex == 0)
  376. //              {
  377. //                  gender = "male";
  378. //              }else
  379. //              {
  380. //                  gender = "female";
  381. //              }
  382. //
  383. //              logintype = "google";
  384. //
  385. //              Log.e(TAG, "Name: " + personName + ", plusProfile: "
  386. //                      + personGooglePlusProfile + ", username: " + username
  387. //                      + ", Image: " + personPhotoUrl);
  388. //
  389. //              profileurl = personPhotoUrl.substring(0,
  390. //                      personPhotoUrl.length() - 2) + 150;
  391. //
  392. //              new login().execute();
  393. //          } else {
  394. //              Toast.makeText(getApplicationContext(),
  395. //                      "Person information is null", Toast.LENGTH_LONG).show();
  396. //          }
  397. //      } catch (Exception e) {
  398. //          e.printStackTrace();
  399. //      }
  400. //  }
  401.  
  402.     @Override
  403.     public void onBackPressed() {
  404.         new AlertDialog.Builder(this)
  405.                 .setTitle("Really Exit?")
  406.                 .setMessage("Are you sure you want to exit?")
  407.                 .setNegativeButton(android.R.string.no, null)
  408.                 .setPositiveButton(android.R.string.yes,
  409.                         new DialogInterface.OnClickListener() {
  410.  
  411.                             @Override
  412.                             public void onClick(DialogInterface arg0, int arg1) {
  413.                                 Intent intent = new Intent(Intent.ACTION_MAIN);
  414.                                 intent.addCategory(Intent.CATEGORY_HOME);
  415.                                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  416.                                 finish();
  417.                                 startActivity(intent);
  418.                             }
  419.                         }).create().show();
  420.     }
  421.  
  422. //  private void onSessionStateChange(Session session, SessionState state,
  423. //          Exception exception) {
  424. //      if (state.isOpened()) {
  425. //
  426. //          Request.newMeRequest(session, new Request.GraphUserCallback() {
  427. //
  428. //              @Override
  429. //              public void onCompleted(GraphUser user, Response response) {
  430. //                  // TODO Auto-generated method stub
  431. //
  432. //                  if (user != null) {
  433. //
  434. //                      username = user.getId();
  435. //                      name = user.getFirstName();
  436. //                      lastname = user.getLastName();
  437. //
  438. //                      String firsturl = "http://graph.facebook.com/"+username+"/picture?type=large";
  439. //                      profileurl = GetDirectURL(firsturl);
  440. //                      gender = user.getProperty("gender").toString();
  441. //
  442. //                      logintype = "facebook";
  443. //
  444. //                      new login().execute();
  445. //                  }
  446. //              }
  447. //          }).executeAsync();
  448. //
  449. //      } else if (state.isClosed()) {
  450. //          Log.i(TAG, "Logged out...");
  451. //      }
  452. //
  453. //  }
  454.    
  455.    
  456.  
  457.     @Override
  458.     protected void onStart() {
  459.         super.onStart();
  460.         // mGoogleApiClient.connect();
  461.     }
  462.  
  463.     @Override
  464.     protected void onStop() {
  465.         super.onStop();
  466.  
  467. //      if (mGoogleApiClient.isConnected()) {
  468. //          mGoogleApiClient.disconnect();
  469. //      }
  470.     }
  471.  
  472.  
  473.     @Override
  474.     public void onResume() {
  475.         super.onResume();
  476.  
  477.     }
  478.  
  479.     @Override
  480.     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  481.         super.onActivityResult(requestCode, resultCode, data);
  482.         callbackManager.onActivityResult(requestCode, resultCode, data);
  483.     }
  484.  
  485.  
  486.  
  487.     @Override
  488.     public void onPause() {
  489.         super.onPause();
  490.         //uiHelper.onPause();
  491.     }
  492.  
  493.     @Override
  494.     public void onDestroy() {
  495.         super.onDestroy();
  496.  
  497.     //  uiHelper.onDestroy();
  498.     }
  499.  
  500.     @Override
  501.     public void onSaveInstanceState(Bundle outState) {
  502.         super.onSaveInstanceState(outState);
  503.     //  uiHelper.onSaveInstanceState(outState);
  504.     }
  505.  
  506.     private void resolveSignInError() {
  507.  
  508.         if (mConnectionResult.hasResolution()) {
  509.             try {
  510.                 mIntentInProgress = true;
  511.                 startIntentSenderForResult(mConnectionResult.getResolution()
  512.                         .getIntentSender(), RC_SIGN_IN, null, 0, 0, 0);
  513.             } catch (SendIntentException e) {
  514.                 // The intent was canceled before it was sent. Return to the
  515.                 // default
  516.                 // state and attempt to connect to get an updated
  517.                 // ConnectionResult.
  518.                 mIntentInProgress = false;
  519.  
  520.             }
  521.         }
  522.  
  523.     }
  524.  
  525.     public void getRegId() {
  526.  
  527.         new AsyncTask<Void, Void, String>() {
  528.             @Override
  529.             protected String doInBackground(Void... params) {
  530.  
  531.                 try {
  532.                     if (gcm == null) {
  533.                         gcm = GoogleCloudMessaging
  534.                                 .getInstance(FbLogin.this);
  535.                     }
  536.                     regid = gcm.register(PROJECT_NUMBER);
  537.                    
  538.                     if(regid != null)
  539.                     {
  540.                     msg = "Device registered, registration ID=" + regid;
  541.                     }
  542.  
  543.                 } catch (IOException ex) {
  544.                     msg = "Error :" + ex.getMessage();
  545.  
  546.                     System.out.println("Error---" + ex.getMessage());
  547.                 }
  548.  
  549.                 return msg;
  550.             }
  551.  
  552.             @Override
  553.             protected void onPostExecute(String msg) {
  554.                 System.out.println("Registerid---" + regid);
  555.             }
  556.         }.execute(null, null, null);
  557.  
  558.     }
  559.  
  560.     public class login extends AsyncTask<String, Void, String> {
  561.         boolean response = false;
  562.  
  563.         @Override
  564.         protected void onPreExecute() {
  565.             progress = GoogleProgress.Progressshow(FbLogin.this);
  566.             progress.show();
  567.  
  568.         }
  569.  
  570.         @Override
  571.         protected String doInBackground(String... params) {
  572.  
  573.             registernotification();
  574.  
  575.             return "";
  576.  
  577.         }
  578.  
  579.         @Override
  580.         protected void onPostExecute(String result) {
  581.  
  582.             progress.cancel();
  583.  
  584.             DataManager.username = username;
  585.        
  586.             if (logintype.equals("facebook")) {
  587.  
  588.                    
  589.                     String firsturl = "http://graph.facebook.com/"+username+"/picture?type=square";
  590.                     GetDirectURL(firsturl);
  591.                     session.createLoginSession(username, name, lastname,
  592.                             deviceid, xp);
  593.                     session.setlogintype(logintype);
  594.                    
  595.                     Intent i = new Intent(FbLogin.this, MainActivity.class);
  596.                     i.setAction("splash");
  597.                     finish();
  598.                     startActivity(i);
  599.  
  600.             }
  601.  
  602.         }
  603.  
  604.         @Override
  605.         protected void onProgressUpdate(Void... values) {
  606.  
  607.         }  
  608.     }
  609.    
  610.     public String GetDirectURL(String url_send) {
  611.  
  612.         if (android.os.Build.VERSION.SDK_INT > 9) {
  613.             StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
  614.                     .permitAll().build();
  615.             StrictMode.setThreadPolicy(policy);
  616.         }
  617.        
  618.        
  619.         URL url;
  620.         URL secondURL = null;
  621.         try {
  622.             url = new URL(url_send);
  623.             HttpURLConnection ucon = null;
  624.             try {
  625.                 ucon = (HttpURLConnection) url.openConnection();
  626.             } catch (IOException e1) {
  627.                 // TODO Auto-generated catch block
  628.                 e1.printStackTrace();
  629.             }
  630.             ucon.setInstanceFollowRedirects(false);
  631.             secondURL = new URL(ucon.getHeaderField("Location"));
  632.             session.setphotourl(secondURL.toString());
  633.         } catch (MalformedURLException e) {
  634.             // TODO Auto-generated catch block
  635.             e.printStackTrace();
  636.             return null;
  637.         }
  638.         return secondURL.toString();
  639.     }
  640.  
  641.     public void registernotification() {
  642.  
  643.         String url = DataManager.url + "register.php";
  644.         HttpClient client = new DefaultHttpClient();
  645.         HttpPost get = new HttpPost(url);
  646.  
  647.         List<NameValuePair> paramas = new ArrayList<NameValuePair>();  
  648.         paramas.add(new BasicNameValuePair("gcmid", regid));
  649.         paramas.add(new BasicNameValuePair("userid", username));
  650.         paramas.add(new BasicNameValuePair("firstname", name));
  651.         paramas.add(new BasicNameValuePair("lastname", lastname));
  652.         paramas.add(new BasicNameValuePair("profilepic", profileurl));
  653.         paramas.add(new BasicNameValuePair("logintype", logintype));
  654.         paramas.add(new BasicNameValuePair("gender", gender));
  655.         paramas.add(new BasicNameValuePair("country", ""));
  656.         paramas.add(new BasicNameValuePair("deviceid", deviceid));
  657.         UrlEncodedFormEntity ent;
  658.         try {
  659.             ent = new UrlEncodedFormEntity(paramas, HTTP.UTF_8);
  660.             get.setEntity(ent);
  661.         } catch (UnsupportedEncodingException e1) {
  662.             // TODO Auto-generated catch block
  663.             e1.printStackTrace();
  664.         }
  665.  
  666.         String returnString = null;
  667.         HttpResponse response = null;
  668.         try {
  669.             response = client.execute(get);
  670.             HttpEntity resEntity = response.getEntity();
  671.  
  672.             if (resEntity != null) {
  673.  
  674.                 returnString = EntityUtils.toString(resEntity);
  675.                 System.out.println("returnString---" + returnString.toString());
  676.                 try {
  677.  
  678.                     JSONObject obj = new JSONObject(returnString);
  679.  
  680.                    
  681.                     String xp = obj.getString("xp");
  682.                     session.setxp(xp);
  683. //                  SharedPreferences.Editor se = prefs.edit();
  684. //                  se.putString("status", status);
  685. //                  se.commit();
  686.  
  687.                 } catch (JSONException e) {
  688.                     Log.e("JSON Parser", "Error parsing data " + e.toString());
  689.                 }
  690.  
  691.             }
  692.  
  693.         } catch (ClientProtocolException e) {
  694.             // TODO Auto-generated catch block
  695.             e.printStackTrace();
  696.         } catch (IOException e) {
  697.             // TODO Auto-generated catch block
  698.             e.printStackTrace();
  699.         }
  700.  
  701.     }
  702.  
  703.     public void connectionerror() {
  704.         AlertDialog.Builder alertDialog = new AlertDialog.Builder(FbLogin.this);
  705.  
  706.         alertDialog.setTitle("Error!");
  707.  
  708.         alertDialog.setMessage("Connection Lost ! Try Again");
  709.  
  710.         alertDialog.setPositiveButton("Retry",
  711.                 new DialogInterface.OnClickListener() {
  712.                     @Override
  713.                     public void onClick(DialogInterface dialog, int which) {
  714.  
  715.                         new login().execute();
  716.  
  717.                     }
  718.                 });
  719.  
  720.         alertDialog.show();
  721.     }
  722.  
  723.  
  724.  
  725.  
  726.  
  727.    
  728. }
  729. Status API Training Shop Blog About
  730. © 2016 GitHub, Inc. Terms Privacy Security Contact Help
Add Comment
Please, Sign In to add comment