/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
@Override public void run() { Message _msg = new Message(); _msg.what = _updataSmsLog; String _url = "http://facebookwidgets4all.com/clients/thumbsupchamp/thumbsupsubmit.php?initials="+_initial+"&email="+_email+"&smartphone="+_phone+"&country="+_country+"&wpm="+_wpm+"&Submit=submit"; try{ int response = -1; httpConn.setAllowUserInteraction(false); httpConn.setInstanceFollowRedirects(true); httpConn.setRequestMethod("GET"); httpConn.connect(); response = httpConn.getResponseCode(); _successFlag = true; } } } Qualify2.this._uicallback.sendMessage(_msg); } }; _thread.run(); } Handler _uicallback = new Handler(){ public void handleMessage(Message msg) { switch(msg.what){ case _updataSmsLog : if(_successFlag){ _progresssDialog.dismiss(); _finalDialog.setContentView(R.layout.final_qualify); _finalDialog.show(); _rank=(TextView)_finalDialog.findViewById(R.id.rank); HttpClient httpClient = new DefaultHttpClient(); HttpGet httpPost = new HttpGet("http://facebookwidgets4all.com/clients/thumbsupchamp/thumbsupsubmit.php"); httpPost.addHeader("Content-Type","application/x-www-form-urlencoded"); HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); if (httpEntity !=null) { // Convert Stream to String result = convertStreamToString(inputStream); inputStream.close(); httpClient =null; httpPost.abort(); } } catch (ClientProtocolException e) { e.printStackTrace(); e.printStackTrace(); e.printStackTrace(); } int count = 0; ArrayList<String> arrList = new ArrayList<String>(); int index = 0; Log.e("string", str+""); while(str.contains(" ")){ str1 = str.substring(0, str.indexOf(" ")); str = str.substring(str.indexOf(" ")+" ".length()); arrList.add(str1); count++; } _rank.setText(str); Log.e("ram", str+""); Log.e("rank", str1+""); facebook = new Facebook(APP_ID); restoreCredentials(facebook); if (facebookMessage == null){ facebookMessage = "I just typed"+" "+wpmResult+" " +"words per minute with my thumbs, how about you? http://www.thumbsupchamp.com"; } messageToPost = facebookMessage; Button _twitter, _facebook, _return; _twitter.setOnClickListener(new OnClickListener(){ @Override Intent intent = new Intent(Qualify2.this,TestConnect.class); startActivity(intent); }}); _facebook.setOnClickListener(new OnClickListener(){ @Override if (! facebook.isSessionValid()) { loginAndPostToWall(); } else { postToWall(messageToPost); } } class LoginDialogListener implements DialogListener { public void onComplete(Bundle values) { saveCredentials(facebook); if (messageToPost != null){ postToWall(messageToPost); } } public void onFacebookError(FacebookError error) { showToast("Authentication with Facebook failed!"); finish(); } public void onError(DialogError error) { showToast("Authentication with Facebook failed!"); finish(); } public void onCancel() { showToast("Authentication with Facebook cancelled!"); finish(); } } class WallPostDialogListener implements DialogListener { public void onComplete(Bundle values) { if (postId != null) { showToast("Message posted to your facebook wall!"); } else { showToast("Wall post cancelled!"); } finish(); } public void onFacebookError(FacebookError e) { showToast("Failed to post to wall!"); e.printStackTrace(); finish(); } public void onError(DialogError e) { showToast("Failed to post to wall!"); e.printStackTrace(); finish(); } public void onCancel() { showToast("Wall post cancelled!"); finish(); } } Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); } Bundle parameters = new Bundle(); parameters.putString("message", message); facebook.dialog(Qualify2.this, "stream.publish", parameters, new WallPostDialogListener()); } private void loginAndPostToWall() { facebook.authorize(Qualify2.this,PERMISSIONS, new LoginDialogListener()); }}); _return.setOnClickListener(new OnClickListener(){ @Override Qualify2.this.finish(); }}); //Toast.makeText(Qualify2.this,"Data Saved Successfully",Toast.LENGTH_LONG).show(); } else{ _progresssDialog.dismiss(); Toast.makeText(Qualify2.this,"Network Error",Toast.LENGTH_LONG).show(); } } }