Wie kann ich einen Code für eine Pebble-App nutzen?

Accy

Ensign
Registriert
Feb. 2014
Beiträge
250
Hey,

ich hab auf Reddit einen Code gefunden, der mir auf meiner Pebble zu wissen gibt, ob ein Pokemon in meiner Nähe ist. :D

Code:
 private void printLogs(){
    try {
        Process process = Runtime.getRuntime().exec("logcat -d");
        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(process.getInputStream()));

        StringBuilder log = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            log.append(line);
        }
        if (log.toString().contains("UpdateMapPokemon")){
            Log.e(MAIN_ACTIVITY_LOG_TAG,"POKEMON UPDATED!");
            Notification.Builder builder = new Notification.Builder(getApplicationContext());
            builder.setContentTitle("New pokemon!");
            builder.setOngoing(false);
            builder.setPriority(Notification.PRIORITY_MAX);
            builder.setSmallIcon(android.R.color.holo_red_dark);
            Notification notification = builder.build();
            NotificationManager notificationManger = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            notificationManger.notify(1, notification);
        }

    } catch (IOException e) {
        Log.d(MAIN_ACTIVITY_LOG_TAG,"FAILED TO READ LOGS");
    }
    new Handler().postDelayed(
            new Runnable() {
                public void run() {
                  printLogs();
                }
            },
            1000);
}

Ich hab allerdings keine Ahnung wie ich diesen Code anwenden kann. Auf Reddit kann das scheinbar jeder, deswegen hat dort niemand nachgefragt, aber ich hab sowas halt noch nie gemacht.

Also vielleicht kann mir hier jemand weiterhelfen mit dem Code und wie ich diese "App" auf meine Uhr bekomme.

Dankeschön. :)
 
Warte einfach bis dort jem,and den Code in eine App gefasst hat.
Der poster des Codes schribe ja schon: "I'll try to create a full open source app this week and if it goes well I'll post it to this sub"
 
Ah ja. Hab ich irgendwie überlesen.

Bin nicht so Reddit konform.

Dankeschön.
 
Zurück
Oben