diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index ea076f1..d4c30bd 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -4,6 +4,10 @@
android:versionCode="2"
android:versionName="1.0.0-SNAPSHOT">
+
+
+
+
{
+
+ @Override
+ protected String doInBackground(String... strings) {
+ try {
+ URL url = new URL(strings[0]);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.connect();
+ String output = readStream(connection.getInputStream());
+ return output;
+ }
+ catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(String s) {
+ super.onPostExecute(s);
+ httptextlog.setText(s);
+ }
+ }
+
+ //credits to John
+ private String readStream(InputStream in) throws IOException {
+ char[] buffer = new char[1024 * 4];
+ InputStreamReader reader = new InputStreamReader(in, "UTF8");
+ StringWriter writer = new StringWriter();
+ int n;
+ while ((n = reader.read(buffer)) != -1) {
+ writer.write(buffer, 0, n);
+ }
+ return writer.toString();
+ }
+
+ class NetworkOKAsyncTask extends AsyncTask {
+
+ @Override
+ protected String doInBackground(String... strings) {
+ String output = "";
+ try {
+ OkHttpClient client = new OkHttpClient();
+ Request request = new Request.Builder().url(strings[0]).build();
+ Response response = client.newCall(request).execute();
+ output = readStream(response.body().byteStream());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return output;
+ }
+
+ @Override
+ protected void onPostExecute(String s) {
+ super.onPostExecute(s);
+ httptextlog.setText(s);
+ }
+ }
}
diff --git a/src/main/java/nyc/c4q/NotificationActivity.java b/src/main/java/nyc/c4q/NotificationActivity.java
index f1f56ad..f79714b 100644
--- a/src/main/java/nyc/c4q/NotificationActivity.java
+++ b/src/main/java/nyc/c4q/NotificationActivity.java
@@ -1,8 +1,10 @@
package nyc.c4q;
import android.app.Activity;
+import android.app.Notification;
import android.app.NotificationManager;
import android.os.Bundle;
+import android.view.View;
import android.widget.Button;
public class NotificationActivity extends Activity {
@@ -25,5 +27,49 @@ protected void onCreate(Bundle savedInstanceState) {
Button dismisspermanentnotification = (Button) findViewById(R.id.dismisspermanentnotification);
Button buttonnotification = (Button) findViewById(R.id.buttonnotification);
+ autocancelnotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Notification auto = new Notification.Builder(getApplicationContext())
+ .setContentTitle("default@c4q.nyc")
+ .setContentText("Touch me to dismiss me!")
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .build();
+ auto.flags = Notification.FLAG_AUTO_CANCEL;
+ notificationManager.notify(ID_AUTOCANCEL_NOTIFICATION, auto);
+ }
+ });
+
+ swipenotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Notification swipe = new Notification.Builder(getApplicationContext())
+ .setContentTitle("swipe@c4q.nyc")
+ .setContentText("Swipe right if you want to meet me. Otherwise, I'm not going away.")
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .build();
+ notificationManager.notify(ID_SWIPE_NOTIFICATION, swipe);
+ }
+ });
+
+ permanentnotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Notification perm = new Notification.Builder(getApplicationContext())
+ .setContentTitle("permanent@c4q.nyc")
+ .setContentText("I'm staying planted right here.")
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setOngoing(true)
+ .build();
+ notificationManager.notify(ID_PERMANENT_NOTIFICATION, perm);
+ }
+ });
+
+ dismisspermanentnotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ notificationManager.cancel(ID_PERMANENT_NOTIFICATION);
+ }
+ });
}
-}
+}
\ No newline at end of file
diff --git a/src/main/res/layout/activity_listview.xml b/src/main/res/layout/activity_listview.xml
index 0d4b9d6..201a9d4 100644
--- a/src/main/res/layout/activity_listview.xml
+++ b/src/main/res/layout/activity_listview.xml
@@ -1,5 +1,4 @@
-
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="3"
+ android:text="You have not clicked anything." />
+
+
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="9" />
\ No newline at end of file