My main action is creating a scene vs. another view, if the user is logged in or not. It checks whether a user is logged in or not, if some shared preferences are entered.
In my head, it determines what this code is shown with this code: If I go to login viewer then the user enters their details and if their login is successful, then I will get the normal R. I would like to go back to switching activities in Latex.active_mail.I am having trouble knowing how to do at the end of my async work: I think your architecture is functionally different from the log-in functionality By doing different activities, namely login activity + welcome activity Before you decide which splash activity to create and use the data shared continuously. In this way you separate the module and call each as needed. override Secure Zero on @ Create (Bundle Saved InstantState) {Super.onCreate (SavedInstanceState); // Check whether the user is logged in myPrefs = this.getSharedPreferences ("myPrefs", MODE_PRIVATE); String prefName = myPrefs.getString ("user name", blank); String userid = myPrefs.getString ("user id", blank); If (prefName == blank & amp; userID == faucet) {setContentView (R. LayOctact_Login); } Else {setContentView (R.layout.activity_main); }
Public Class ReadLogInJSON AsyncTask & lt; String, zero, string & gt; {Reference C; Public Reedlog Ingestion (reference reference) {c = context; } @ Override protected string doInBackground (string ... arg0) {// TODO auto generated method stub returns Jasonfid (Arg 0 [0]); } Protected Zero PostExecute (string result) {// decode Jason Try Here {JSONObject json = New JSONObject (Results); String position = json.getString ("status"); If (status.equals ("no")) // // toast login failed string message = "login failed"; Toast. Make Text (C, Message, Toast. LNNGHHORAT) Show (); } Else {// Username string user name = json.getString ("userName"); // User ID string UserID = json.getString ("userID"); // Set Priorities Sharing Options Preference = PreferenceManager.getDefaultSharedPreferences (c); SharedPreferences.Editor Editor = preferences.edit (); Editor.putString ("username", user name); Editor.putString ("user id", userID); Editor.commit (); // Launch General Activity Intent i = New Intent (C, Main Activity class); I.setClass (c, main activity category); StartActivity (i); }} Hold (exception e) {}} public string readJSONFeed (string url) {stringbiller stringbiller = new stringbilder (); HTTP Client HTTP Client = New DefaultHttpClient (); HttpGet httpGet = New HttpGet (URL); Try {HttpResponse response = httpClient.execute (httpGet); Threaded Positions = Response .getStatusLine (); Int statusCode = statusLine.getStatusCode (); If (statusCode == 200) {HttpEntity entity = response.getEntity (); InputStream inputstream = entity.getContent (); BufferedReader Reader = New BufferedReader (New InputStreamReader (InputStream)); String line; While ((line = reader.readline ()) = faucet {stringBuilder.append (line); } Inputstream.close (); } Else {Log.d ("JSON", "Failed to download file"); }} Hold (exception e) {log d. ("ReadJSONFeed", E..T.O.Localized Message ()); } Return stringBuilder. Toasting (); }}
No comments:
Post a Comment