diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index ea076f1..c06e122 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -4,6 +4,9 @@ android:versionCode="2" android:versionName="1.0.0-SNAPSHOT"> + + + pairs = new ArrayList(); + pairs.add(new BasicNameValuePair("key1", "value1")); + pairs.add(new BasicNameValuePair("key2", "value2")); + try { + post.setEntity(new UrlEncodedFormEntity(pairs)); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + try { + HttpResponse response = client.execute(post); + httptextlog.setText(response.toString()); + + } catch (IOException e) { + e.printStackTrace(); + } + } }); @@ -104,4 +129,45 @@ public void onClick(View v) { } }); } + + + public static String GET(String url){ + InputStream inputStream = null; + String result = ""; + try { + // create HttpClient + HttpClient httpclient = new DefaultHttpClient(); + + // make GET request to the given URL + HttpResponse httpResponse = httpclient.execute(new HttpGet(url)); + + // receive response as inputStream + inputStream = httpResponse.getEntity().getContent(); + + // convert inputstream to string + if(inputStream != null) + result = convertInputStreamToString(inputStream); + else + result = "Did not work!"; + + } catch (Exception e) { + Log.d("InputStream", e.getLocalizedMessage()); + } + + return result; + } + + // convert inputstream to String + private static String convertInputStreamToString(InputStream inputStream) throws IOException { + BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); + String line = ""; + String result = ""; + while((line = bufferedReader.readLine()) != null) + result += line; + + inputStream.close(); + return result; + } + + } diff --git a/src/main/java/nyc/c4q/NotificationActivity.java b/src/main/java/nyc/c4q/NotificationActivity.java index f1f56ad..ec226d8 100644 --- a/src/main/java/nyc/c4q/NotificationActivity.java +++ b/src/main/java/nyc/c4q/NotificationActivity.java @@ -1,8 +1,13 @@ package nyc.c4q; import android.app.Activity; +import android.app.Notification; import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.NotificationCompat; +import android.view.View; import android.widget.Button; public class NotificationActivity extends Activity { @@ -17,13 +22,46 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notification); - notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - Button autocancelnotification = (Button) findViewById(R.id.autocancelnotification); Button swipenotification = (Button) findViewById(R.id.swipenotification); Button permanentnotification = (Button) findViewById(R.id.permanentnotification); Button dismisspermanentnotification = (Button) findViewById(R.id.dismisspermanentnotification); Button buttonnotification = (Button) findViewById(R.id.buttonnotification); + autocancelnotification.setOnClickListener(autocancelListener); + + + + + + } + + public void createNotification (String contentTitle, String contentText, int id){ + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + + NotificationCompat.Builder builder = new NotificationCompat.Builder(this); + builder.setAutoCancel(true); + + builder.setContentTitle(contentTitle); + builder.setContentText(contentText); + builder.setSmallIcon(R.drawable.c4qfavicon); + + //pendingIntent + Intent resultIntent = new Intent (this, NotificationActivity.class); + PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); + builder.setContentIntent(pendingIntent); + + Notification notification = builder.build(); + notificationManager.notify(id, notification); } + + public View.OnClickListener autocancelListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + + createNotification("default@c4q.nyc", "Touch me to dismiss me!", ID_AUTOCANCEL_NOTIFICATION ); + + } + + }; } diff --git a/src/main/java/nyc/c4q/json/Zipcode.java b/src/main/java/nyc/c4q/json/Zipcode.java index 6d4761f..b5aa42f 100644 --- a/src/main/java/nyc/c4q/json/Zipcode.java +++ b/src/main/java/nyc/c4q/json/Zipcode.java @@ -1,4 +1,7 @@ package nyc.c4q.json; public class Zipcode { + + + } diff --git a/src/main/res/layout/activity_listview.xml b/src/main/res/layout/activity_listview.xml index 0d4b9d6..59a342f 100644 --- a/src/main/res/layout/activity_listview.xml +++ b/src/main/res/layout/activity_listview.xml @@ -9,20 +9,31 @@ + android:layout_weight="3" + android:layout_width="0dp" + android:layout_height="match_parent" + android:text="You have not clicked anything." /> + + + android:layout_weight="9" + android:layout_width="match_parent" + android:layout_height="0dp"/> + \ No newline at end of file