Example usage for android.os Message getData

List of usage examples for android.os Message getData

Introduction

In this page you can find the example usage for android.os Message getData.

Prototype

public Bundle getData() 

Source Link

Document

Obtains a Bundle of arbitrary data associated with this event, lazily creating it if necessary.

Usage

From source file:org.crossconnect.bible.activity.main.BibleTextFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    bibleScrollView = (BibleTextScrollView) getActivity().findViewById(R.id.bibleScrollView);

    //Handler created on UI thread to handle updates to title
    updateTitleHandler = new Handler() {
        @Override/*from  w  w w. j a va  2s.  com*/
        public void handleMessage(Message msg) {

            final String verseText = msg.getData().getString("Verse_Text");
            ((MainActivity) getActivity()).updateHeaderText(
                    bibleTextView.getBibleText().getDisplayReferenceBookChapter() + verseText);
        }

    };
    bibleScrollView.setTitleHandler(updateTitleHandler);

    bibleTextView = (BibleTextView) getActivity().findViewById(R.id.bible_text);
    bibleTextView.setBibleSrcollView(bibleScrollView);

    loadSettings();

    //Previous chapter button
    ((Button) getActivity().findViewById(R.id.prev_chapter_button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Start thread to get verse
            getActivity().showDialog(LOADING_DIALOG);
            new SwordVerseTask().execute(bibleTextView.getBibleText().getPrevChapterRef());
        }

    });

    //Next chapter button
    ((Button) getActivity().findViewById(R.id.next_chapter_button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Start thread to get verse
            getActivity().showDialog(LOADING_DIALOG);
            new SwordVerseTask().execute(bibleTextView.getBibleText().getNextChapterRef());
        }

    });

    //Go to windows view
    ((ImageButton) getActivity().findViewById(R.id.menu_button_windows))
            .setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), WindowsActivity.class);

                    //Set the verseNumber to what is currently being viewed
                    int verseNumber = bibleTextView.yToVerse(bibleScrollView.getScrollY(),
                            (getActivity().findViewById(R.id.prev_chapter_button)).getHeight());

                    Log.i("Main", "Set BibleTextView verse number " + verseNumber);

                    bibleTextView.getBibleText().setVerse(verseNumber);

                    Log.i("Main", "BibleTextView sent "
                            + bibleTextView.getBibleText().getReferenceBookChapterVerse());

                    //TODO: add string preview  from existing rendered text probably just do a substring of boundaries
                    intent.putExtra("BibleText", bibleTextView.getBibleText());
                    intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId);
                    startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE);
                    //                overridePendingTransition(R.anim.zoom_enter, 0);

                }
            });

    //Go to tabs view
    ((ImageButton) getActivity().findViewById(R.id.menu_button_tabs)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), TabsActivity.class);

            //Set the verseNumber to what is currently being viewed
            int verseNumber = bibleTextView.yToVerse(bibleScrollView.getScrollY(),
                    (getActivity().findViewById(R.id.prev_chapter_button)).getHeight());

            Log.i("Main", "Set BibleTextView verse number " + verseNumber);

            bibleTextView.getBibleText().setVerse(verseNumber);

            Log.i("Main", "BibleTextView sent " + bibleTextView.getBibleText().getReferenceBookChapterVerse());

            //TODO: add string preview  from existing rendered text probably just do a substring of boundaries
            intent.putExtra("BibleText", bibleTextView.getBibleText());
            intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId);
            startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE);
            //                overridePendingTransition(R.anim.zoom_enter, 0);

        }
    });

    if (bibleTextView.getBibleText() == null) {
        //Load last opened verse
        String currentBook = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString(SharedPreferencesHelper.CURRENT_BOOK, "Philipiians");
        String currentChapter = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString(SharedPreferencesHelper.CURRENT_CHAPTER, "1");
        String currentVerse = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString(SharedPreferencesHelper.CURRENT_VERSE, "1");
        String currentTranslation = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString(SharedPreferencesHelper.CURRENT_TRANSLATION, "ESV");
        new SwordInitTask().execute(currentBook, currentChapter, currentVerse, currentTranslation);
    }

    //        // Give some text to display if there is no data. In a real
    //        // application this would come from a resource.
    //        setEmptyText("No applications");
    //
    //        // We have a menu item to show in action bar.
    //        setHasOptionsMenu(true);
    //
    //        // Only have one choice
    //        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    //
    //        // Create an empty adapter we will use to display the loaded data.
    //        mAdapter = new AppListAdapter(getActivity());
    //        setListAdapter(mAdapter);
    //
    //        // Start out with a progress indicator.
    //        setListShown(false);

    // Prepare the loader. Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}

From source file:ti.modules.titanium.geolocation.GeolocationModule.java

@Kroll.method
public void reverseGeocoder(double latitude, double longitude, KrollCallback callback) {
    String mid = TiPlatformHelper.getMobileId();
    String aguid = getTiContext().getTiApp().getAppInfo().getGUID();
    String sid = TiPlatformHelper.getSessionId();
    String countryCode = Locale.getDefault().getCountry();

    String url = buildGeoURL("r", mid, aguid, sid, latitude + "," + longitude, countryCode);

    if (url != null) {
        Message msg = getUIHandler().obtainMessage(MSG_LOOKUP);
        msg.getData().putString("direction", "r");
        msg.getData().putString("url", url);
        msg.obj = callback;//w ww.ja v a2 s. c o  m
        msg.sendToTarget();
    }
}

From source file:com.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java

/**
 * Process the error message dialog as per the data recevied
 *
 * @param msg/*from  ww w .  ja va2s .  c  o  m*/
 */
private void processError(Message msg) {
    try {
        Bundle data = msg.getData();
        if (data != null) {
            if (data.getBoolean(cancelFlag)) {
                showErrorDialog(data.getString(errMessage), data.getBoolean(cancelFlag));
            } else {
                showErrorDialog(data.getString(errMessage));
            }
        }

    } catch (Exception ex) {
        PhrescoLogger.info(TAG + " - splashHandler  - Exception : " + ex.toString());
        PhrescoLogger.warning(ex);
    }
}

From source file:net.networksaremadeofstring.rhybudd.DeviceList.java

/** Called when the activity is first created. */
@SuppressWarnings({ "unchecked", "deprecation" })
@Override//from   w ww . jav a 2s  .  c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    settings = PreferenceManager.getDefaultSharedPreferences(this);

    setContentView(R.layout.devicelist);
    BugSenseHandler.initAndStartSession(DeviceList.this, "44a76a8c");

    actionbar = getActionBar();
    actionbar.setDisplayHomeAsUpEnabled(true);
    actionbar.setHomeButtonEnabled(true);
    actionbar.setTitle("Infrastructure");

    list = (ListView) findViewById(R.id.ZenossDeviceList);

    BugSenseHandler.initAndStartSession(DeviceList.this, "44a76a8c");

    handler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
                Toast.makeText(DeviceList.this,
                        "An error was encountered;\r\n" + msg.getData().getString("exception"),
                        Toast.LENGTH_LONG).show();
            } else if (msg.what == 1) {
                dialog.setMessage("Refresh Complete!");
                this.sendEmptyMessageDelayed(2, 1000);
            } else if (msg.what == 2) {
                dialog.dismiss();
                adapter = new ZenossDeviceAdaptor(DeviceList.this, listOfZenossDevices);
                list.setAdapter(adapter);
                ((TextView) findViewById(R.id.ServerCountLabel))
                        .setText("Monitoring " + DeviceCount + " servers");
            }
        }
    };

    try {
        listOfZenossDevices = (List<ZenossDevice>) getLastNonConfigurationInstance();
    } catch (Exception e) {
        listOfZenossDevices = null;
        //BugSenseHandler.log("DeviceList", e);
    }

    if (listOfZenossDevices == null || listOfZenossDevices.size() < 1) {
        listOfZenossDevices = new ArrayList<ZenossDevice>();
        DBGetThread();
    } else {
        adapter = new ZenossDeviceAdaptor(DeviceList.this, listOfZenossDevices);
        list.setAdapter(adapter);
    }
}

From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvUserIdsFragment.java

private void addUserId() {
    Handler returnHandler = new Handler() {
        @Override/*from ww w  . j a  v a 2s . co  m*/
        public void handleMessage(Message message) {
            if (message.what == SetPassphraseDialogFragment.MESSAGE_OKAY) {
                Bundle data = message.getData();

                // add new user id
                mUserIdsAddedAdapter.add(data.getString(AddUserIdDialogFragment.MESSAGE_DATA_USER_ID));
            }
        }
    };

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(returnHandler);

    // pre-fill out primary name
    AddUserIdDialogFragment addUserIdDialog = AddUserIdDialogFragment.newInstance(messenger, "");

    addUserIdDialog.show(getActivity().getSupportFragmentManager(), "addUserIdDialog");
}

From source file:ti.modules.titanium.geolocation.GeolocationModule.java

@Kroll.method
public void forwardGeocoder(String address, KrollCallback listener) {
    if (address != null) {
        String mid = TiPlatformHelper.getMobileId();
        String aguid = getTiContext().getTiApp().getAppInfo().getGUID();
        String sid = TiPlatformHelper.getSessionId();
        String countryCode = Locale.getDefault().getCountry();

        String url = buildGeoURL("f", mid, aguid, sid, address, countryCode);

        if (url != null) {
            Message msg = getUIHandler().obtainMessage(MSG_LOOKUP);
            msg.getData().putString("direction", "f");
            msg.getData().putString("url", url);
            msg.obj = listener;//from   ww w .j  ava  2s .  c  om
            msg.sendToTarget();
        }
    } else {
        Log.w(LCAT, "Address should not be null.");
    }
}

From source file:thproject.test.com.myapplication.SongRecognitionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_song_recognition);

    context = getApplicationContext();/*from   w  w w. j  av  a  2  s.  c  o m*/

    //handler for events within activity
    handler = new Handler() {
        public void handleMessage(Message msg) {
            Bundle data = msg.getData();
            String artist = data.getString("artist");
            String album = data.getString("album");
            String action = data.getString("action");

            //First action occurs when no tabs are present, progress dialog shown
            if (action.compareTo("test") == 0) {
                Toast.makeText(getApplicationContext(), artist + " " + album, Toast.LENGTH_SHORT).show();
            }
            //Action to show our list of albums
            if (action.compareTo("albums") == 0) {
                showAlbumDialog();
            }
            //Action to show our list of tracks
            if (action.compareTo("tracks") == 0) {
                int index = data.getInt("albumIndex");
                GnAlbum selectedAlbum = albumObjects.get(index);
                showTracksDialog(selectedAlbum);
            }
            //Actino to begin scraping
            if (action.compareTo("scrape") == 0) {
                beginScraping();
            }
            //show progress
            if (action.compareTo("showprogress") == 0) {
                progressDialog = new ProgressDialog(SongRecognitionActivity.this);
                progressDialog.setMessage("Loading tab ");
                progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                progressDialog.show();
            }

            //hide progress
            if (action.compareTo("stopprogress") == 0) {
                progressDialog.hide();
            }

            //update progress
            if (action.compareTo("progresstext") == 0) {
                String text = data.getString("text");
                progressDialog.setMessage("Loading tab " + text);
            }

            //Action to exit this activity
            if (action.compareTo("exit") == 0) {
                Intent i;
                i = new Intent(SongRecognitionActivity.this, MainTabActivity.class);
                startActivity(i);
                finish();
            }
        }
    };
    //Executing asynchronous connection
    new gnSync().execute();

    //disable application icon from ActionBar, set up remaining attributes
    ActionBar actionBar = getActionBar();
    actionBar.hide();
}

From source file:edu.iub.seclab.appguardian.AppGuardianService.java

@Override
public void onCreate() {
    Intent notificationIntent = new Intent(this, AppGuardianMainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    Notification notification = new NotificationCompat.Builder(this).setContentTitle("App Guardian")
            .setContentText("App Guardian is protecting your device.").setSmallIcon(R.drawable.ic_launcher)
            .setContentIntent(pendingIntent).setOngoing(true).build();

    startForeground(NOTIFICATION_ID, notification);

    mTargetList = new TargetList();

    final Context currentctx = this;
    handler = new Handler() {
        public void handleMessage(Message msg) {
            int type = msg.getData().getInt("type");
            switch (type) {
            case TARGET_RUNNING:
                new Thread(new monitorTargetTask()).start();
                break;
            case TARGET_TIMEDOUT:
                restoreTask();/*from   w w w.j  a va 2  s  .c  om*/
                break;
            }
        }
    };
}

From source file:org.sufficientlysecure.keychain.ui.EncryptFileActivity.java

private void copyToClipboard(Message message) {
    ClipboardReflection.copyToClipboard(this,
            new String(message.getData().getByteArray(KeychainIntentService.RESULT_BYTES)));
}

From source file:com.crossconnect.activity.main.BibleTextFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    bibleScrollView = (BibleTextScrollView) getActivity().findViewById(R.id.bibleScrollView);

    //Handler created on UI thread to handle updates to title
    updateTitleHandler = new Handler() {
        @Override/*from   w  w w  .  j  a v a2s.c om*/
        public void handleMessage(Message msg) {

            final String verseText = msg.getData().getString("Verse_Text");
            ((MainActivity) getActivity()).updateHeaderText(
                    bibleTextView.getBibleText().getDisplayReferenceBookChapter() + verseText);
        }

    };
    bibleScrollView.setTitleHandler(updateTitleHandler);

    bibleTextView = (BibleTextView) getActivity().findViewById(R.id.bible_text);
    bibleTextView.setBibleSrcollView(bibleScrollView);

    loadSettings();

    //Previous chapter button
    ((Button) getActivity().findViewById(R.id.prev_chapter_button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Start thread to get verse
            getActivity().showDialog(LOADING_DIALOG);
            new SwordVerseTask().execute(bibleTextView.getBibleText().getPrevChapterRef());
        }

    });

    //Next chapter button
    ((Button) getActivity().findViewById(R.id.next_chapter_button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Start thread to get verse
            getActivity().showDialog(LOADING_DIALOG);
            new SwordVerseTask().execute(bibleTextView.getBibleText().getNextChapterRef());
        }

    });

    //Go to windows view
    ((ImageButton) getActivity().findViewById(R.id.menu_button_windows))
            .setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), WindowsActivity.class);

                    //Set the verseNumber to what is currently being viewed
                    int verseNumber = bibleTextView.yToVerse(bibleScrollView.getScrollY(),
                            (getActivity().findViewById(R.id.prev_chapter_button)).getHeight());

                    Log.i("Main", "Set BibleTextView verse number " + verseNumber);

                    bibleTextView.getBibleText().setVerse(verseNumber);

                    Log.i("Main", "BibleTextView sent "
                            + bibleTextView.getBibleText().getReferenceBookChapterVerse());

                    //TODO: add string preview  from existing rendered text probably just do a substring of boundaries
                    intent.putExtra("BibleText", bibleTextView.getBibleText());
                    intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId);
                    startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE);
                    //                overridePendingTransition(R.anim.zoom_enter, 0);

                }
            });

    //Go to tabs view
    ((ImageButton) getActivity().findViewById(R.id.menu_button_tabs)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), TabsActivity.class);

            //Set the verseNumber to what is currently being viewed
            int verseNumber = bibleTextView.yToVerse(bibleScrollView.getScrollY(),
                    (getActivity().findViewById(R.id.prev_chapter_button)).getHeight());

            Log.i("Main", "Set BibleTextView verse number " + verseNumber);

            bibleTextView.getBibleText().setVerse(verseNumber);

            Log.i("Main", "BibleTextView sent " + bibleTextView.getBibleText().getReferenceBookChapterVerse());

            //TODO: add string preview  from existing rendered text probably just do a substring of boundaries
            intent.putExtra("BibleText", bibleTextView.getBibleText());
            intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId);
            startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE);
            //                overridePendingTransition(R.anim.zoom_enter, 0);

        }
    });

    if (bibleTextView.getBibleText() == null) {
        //Load last opened verse
        String currentBook = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString("SharedPreferencesHelper.CURRENT_BOOK", "Philipiians");
        String currentChapter = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString("SharedPreferencesHelper.CURRENT_CHAPTER", "1");
        String currentVerse = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString("SharedPreferencesHelper.CURRENT_VERSE", "1");
        String currentTranslation = getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE)
                .getString("SharedPreferencesHelper.CURRENT_TRANSLATION", "ESV");
        new SwordInitTask().execute(currentBook, currentChapter, currentVerse, currentTranslation);
    }

    //        // Give some text to display if there is no data. In a real
    //        // application this would come from a resource.
    //        setEmptyText("No applications");
    //
    //        // We have a menu item to show in action bar.
    //        setHasOptionsMenu(true);
    //
    //        // Only have one choice
    //        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    //
    //        // Create an empty adapter we will use to display the loaded data.
    //        mAdapter = new AppListAdapter(getActivity());
    //        setListAdapter(mAdapter);
    //
    //        // Start out with a progress indicator.
    //        setListShown(false);

    // Prepare the loader. Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}