fork download
  1. class RegisterInBackground extends AsyncTask<String,String,String>
  2. {
  3. // tread in the background
  4. @Override
  5. protected String doInBackground(String... arg0) {
  6.  
  7. String msg="";
  8. try
  9. {
  10. if(gcm== null)
  11. {
  12. gcm = GoogleCloudMessaging.getInstance(context);
  13. }
  14. regid = gcm.register(SENDER_ID);
  15. msg = "Registration was succesfull, ID of your device is " + regid;
  16.  
  17.  
  18. // now we try with airbop so the this method is commented
  19. if(sendRegistrationIdToBackend(regid))
  20. {
  21.  
  22. }
  23. else
  24. {
  25. msg = "something wrong is here";
  26. }
  27.  
  28. } catch(IOException ex)
  29. {
  30. msg = "Error :" + ex.getMessage();
  31. }
  32. return msg;
  33. }
  34. // after tread in the background ends
  35. @Override
  36. protected void onPostExecute(String msg) {
  37. showInfo.setText(msg);
  38. serverInfo.setText(serverInfoString);
  39.  
  40. }
  41.  
  42. //Map<String, String> params
  43. private boolean sendRegistrationIdToBackend(String regid) throws IOException
  44. {
  45.  
  46. // code from techlovejump the notification
  47. String url = "http://w...content-available-to-author-only...l.pl/reg.php";
  48. List<NameValuePair> datapairs = new ArrayList<NameValuePair>();
  49. datapairs.add(new BasicNameValuePair("regid", regid));
  50. DefaultHttpClient httpClient = new DefaultHttpClient();
  51. HttpPost httpPost = new HttpPost(url);
  52. try {
  53. httpPost.setEntity(new UrlEncodedFormEntity(datapairs));
  54. // TODO Auto-generated catch block
  55. e1.printStackTrace();
  56. }
  57.  
  58. try {
  59. HttpResponse httpResponse = httpClient.execute(httpPost);
  60. serverInfoString = "everything right";
  61.  
  62. } catch (ClientProtocolException e) {
  63. // TODO Auto-generated catch block
  64. e.printStackTrace();
  65. serverInfoString = "CliengProtocolException";
  66. return false;
  67. } catch (IOException e) {
  68. // TODO Auto-generated catch block
  69. e.printStackTrace();
  70. serverInfoString = "IOException";
  71. return false;
  72. }
  73. return true;
  74. }
  75.  
  76. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: cannot find symbol
class RegisterInBackground extends AsyncTask<String,String,String>
                                   ^
  symbol: class AsyncTask
Main.java:43: error: cannot find symbol
		private boolean sendRegistrationIdToBackend(String regid) throws IOException
		                                                                 ^
  symbol:   class IOException
  location: class RegisterInBackground
Main.java:10: error: cannot find symbol
				if(gcm== null)
				   ^
  symbol:   variable gcm
  location: class RegisterInBackground
Main.java:12: error: cannot find symbol
					gcm = GoogleCloudMessaging.getInstance(context);
					^
  symbol:   variable gcm
  location: class RegisterInBackground
Main.java:12: error: cannot find symbol
					gcm = GoogleCloudMessaging.getInstance(context);
					                                       ^
  symbol:   variable context
  location: class RegisterInBackground
Main.java:12: error: cannot find symbol
					gcm = GoogleCloudMessaging.getInstance(context);
					      ^
  symbol:   variable GoogleCloudMessaging
  location: class RegisterInBackground
Main.java:14: error: cannot find symbol
				regid = gcm.register(SENDER_ID);
				^
  symbol:   variable regid
  location: class RegisterInBackground
Main.java:14: error: cannot find symbol
				regid = gcm.register(SENDER_ID);
				                     ^
  symbol:   variable SENDER_ID
  location: class RegisterInBackground
Main.java:14: error: cannot find symbol
				regid = gcm.register(SENDER_ID);
				        ^
  symbol:   variable gcm
  location: class RegisterInBackground
Main.java:15: error: cannot find symbol
				msg = "Registration was succesfull, ID of your device is " + regid;
				                                                             ^
  symbol:   variable regid
  location: class RegisterInBackground
Main.java:19: error: cannot find symbol
				if(sendRegistrationIdToBackend(regid))
				                               ^
  symbol:   variable regid
  location: class RegisterInBackground
Main.java:28: error: cannot find symbol
			} catch(IOException ex)
			        ^
  symbol:   class IOException
  location: class RegisterInBackground
Main.java:4: error: method does not override or implement a method from a supertype
		@Override
		^
Main.java:37: error: cannot find symbol
			showInfo.setText(msg);
			^
  symbol:   variable showInfo
  location: class RegisterInBackground
Main.java:38: error: cannot find symbol
			serverInfo.setText(serverInfoString);
			                   ^
  symbol:   variable serverInfoString
  location: class RegisterInBackground
Main.java:38: error: cannot find symbol
			serverInfo.setText(serverInfoString);
			^
  symbol:   variable serverInfo
  location: class RegisterInBackground
Main.java:35: error: method does not override or implement a method from a supertype
		@Override
		^
Main.java:48: error: cannot find symbol
			List<NameValuePair> datapairs  = new ArrayList<NameValuePair>();
			^
  symbol:   class List
  location: class RegisterInBackground
Main.java:48: error: cannot find symbol
			List<NameValuePair> datapairs  = new ArrayList<NameValuePair>();
			     ^
  symbol:   class NameValuePair
  location: class RegisterInBackground
Main.java:48: error: cannot find symbol
			List<NameValuePair> datapairs  = new ArrayList<NameValuePair>();
			                                     ^
  symbol:   class ArrayList
  location: class RegisterInBackground
Main.java:48: error: cannot find symbol
			List<NameValuePair> datapairs  = new ArrayList<NameValuePair>();
			                                               ^
  symbol:   class NameValuePair
  location: class RegisterInBackground
Main.java:49: error: cannot find symbol
			datapairs.add(new BasicNameValuePair("regid", regid));
			                  ^
  symbol:   class BasicNameValuePair
  location: class RegisterInBackground
Main.java:50: error: cannot find symbol
			DefaultHttpClient httpClient = new DefaultHttpClient();
			^
  symbol:   class DefaultHttpClient
  location: class RegisterInBackground
Main.java:50: error: cannot find symbol
			DefaultHttpClient httpClient = new DefaultHttpClient();
			                                   ^
  symbol:   class DefaultHttpClient
  location: class RegisterInBackground
Main.java:51: error: cannot find symbol
			HttpPost httpPost = new HttpPost(url);
			^
  symbol:   class HttpPost
  location: class RegisterInBackground
Main.java:51: error: cannot find symbol
			HttpPost httpPost = new HttpPost(url);
			                        ^
  symbol:   class HttpPost
  location: class RegisterInBackground
Main.java:53: error: cannot find symbol
				httpPost.setEntity(new UrlEncodedFormEntity(datapairs));
				                       ^
  symbol:   class UrlEncodedFormEntity
  location: class RegisterInBackground
Main.java:54: error: cannot find symbol
			} catch (UnsupportedEncodingException e1) {
			         ^
  symbol:   class UnsupportedEncodingException
  location: class RegisterInBackground
Main.java:60: error: cannot find symbol
				HttpResponse httpResponse = httpClient.execute(httpPost);
				^
  symbol:   class HttpResponse
  location: class RegisterInBackground
Main.java:61: error: cannot find symbol
				serverInfoString = "everything right";
				^
  symbol:   variable serverInfoString
  location: class RegisterInBackground
Main.java:63: error: cannot find symbol
            } catch (ClientProtocolException e) {
                     ^
  symbol:   class ClientProtocolException
  location: class RegisterInBackground
Main.java:66: error: cannot find symbol
				serverInfoString = "CliengProtocolException";
				^
  symbol:   variable serverInfoString
  location: class RegisterInBackground
Main.java:68: error: cannot find symbol
			} catch (IOException e) {
			         ^
  symbol:   class IOException
  location: class RegisterInBackground
Main.java:71: error: cannot find symbol
				serverInfoString = "IOException";	
				^
  symbol:   variable serverInfoString
  location: class RegisterInBackground
34 errors
stdout
Standard output is empty