Android Open Source - dNote D M Save From Wear






From Project

Back to project page dNote.

License

The source code is released under:

GNU General Public License

If you think the Android project dNote listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.digutsoft.note;
/*w  ww .ja v a 2  s .  c om*/
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v4.app.NotificationCompat;

import com.digutsoft.note.classes.DMMemoTools;
import com.google.android.gms.wearable.MessageEvent;
import com.google.android.gms.wearable.WearableListenerService;

public class DMSaveFromWear extends WearableListenerService {
    private static final String dNoteSaveNote = "/dNote-Save-Note";

    @Override
    public void onMessageReceived(MessageEvent messageEvent) {
        if (messageEvent.getPath().equals(dNoteSaveNote)) {
            String wearNoteContent = new String(messageEvent.getData());
            String wearNoteCategory = getString(R.string.sf_wearable);

            DMMemoTools.createCategory(getApplicationContext(), wearNoteCategory);
            switch (DMMemoTools.saveMemo(getApplicationContext(), wearNoteCategory, wearNoteContent)) {
                case 0:
                    Intent intStartView = new Intent(getApplicationContext(), DMMain.class);
                    intStartView.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intStartView.putExtra("mvCategoryName", wearNoteCategory);
                    startActivity(intStartView);
                    break;
                default:
                    NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
                    Notification notification;
                    Intent intent = new Intent(getApplicationContext(), DMSaveFrom.class);
                    intent.putExtra(Intent.EXTRA_TEXT, new String(messageEvent.getData()));
                    PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        notification = new NotificationCompat.Builder(getApplicationContext())
                                .setContentTitle(getString(R.string.sf_wearable_fail))
                                .setContentText(getString(R.string.sf_wearable_fail_message))
                                .setTicker(getString(R.string.sf_wearable_fail))
                                .setContentIntent(pendingIntent)
                                .setSmallIcon(R.drawable.ic_launcher)
                                .build();
                    } else {
                        notification = new Notification(R.drawable.ic_launcher, null, System.currentTimeMillis());
                        notification.tickerText = getString(R.string.sf_wearable_fail);
                        notification.setLatestEventInfo(getApplicationContext(), getString(R.string.sf_wearable_fail), getString(R.string.sf_wearable_fail_message), pendingIntent);
                    }

                    notificationManager.notify(1, notification);
                    break;
            }
        }
    }
}




Java Source Code List

android.support.v4.preference.PreferenceFragment.java
android.support.v4.preference.PreferenceManagerCompat.java
android.support.v4.preferencefragment.BuildConfig.java
android.support.v4.preferencefragment.BuildConfig.java
com.digutsoft.note.DMCategoryManager.java
com.digutsoft.note.DMMain.java
com.digutsoft.note.DMMemoView.java
com.digutsoft.note.DMNewNote.java
com.digutsoft.note.DMSaveFromWear.java
com.digutsoft.note.DMSaveFrom.java
com.digutsoft.note.DMSettingsFragment.java
com.digutsoft.note.DMSettings.java
com.digutsoft.note.DMSplash.java
com.digutsoft.note.DMWearVoiceAction.java
com.digutsoft.note.DrawerMenuList.java
com.digutsoft.note.NavigationDrawerFragment.java
com.digutsoft.note.classes.DMDatabaseHelper.java
com.digutsoft.note.classes.DMMemoList.java
com.digutsoft.note.classes.DMMemoTools.java