Notification assistance.

by Damien Cooke » Sun, 12 Dec 2010 12:14:13 GMT


Sponsored Links
 Hi All,
I am crossing from iOS to Android development and am after a small amount of 
help with a concept.  In ios I can post notifications that can be listed for by 
other objects.  These are not seen by the user, they are totally internal to 
the application.  Is this type of systemic messaging available or do I need to 
more closely couple my classes?  or even completely rethink my design?

Thanks and sorry for the dumb question
Damien

-- 



Re: Notification assistance.

by DanH » Sun, 12 Dec 2010 13:03:58 GMT


 In Android the same basic function is accomplished with "intents".




-- 


Sponsored Links


Re: Re: Notification assistance.

by Dianne Hackborn » Mon, 13 Dec 2010 00:10:08 GMT


 



Well.  If this is all just in your app, I would generally just recommend
doing normal direct callbacks.  There isn't a generic "local callback
registry" API in Android, but this is trivial to build yourself -- just make
a class with an ArrayList<Callback> and functions to add and remove
callbacks, and perform a call on all callbacks.  It's 20 lines of code max.
 If you want to make it async, it's a couple more lines of code to have a
Handler that you post a Runnable on to, to do the callbacks.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Re: Notification assistance.

by Phil Endecott » Mon, 13 Dec 2010 03:20:52 GMT


 Hi Damien,




Write your own replacement.  On iOS I use my own simple notification
system, because Apple's version is overcomplicated.  For most cases
it's almost trivial to do; it only gets complicated if you need to
worry about threads, queuing, merging multiple notifications and
things like that.

-- 



Other Threads

1. twtpic4j is not throwing exception

I am using this following function f1() in am android project... the
last line of the function SHOULD throw an exception as the twitter
username password is not correct, but it is not.. am I missing
anything here?

private void f1() {
                try {
                        // Create file

                        File f =new 
File(Environment.getExternalStorageDirectory(),
                        "gallery_pic.jpeg");
                        InputStream inputStream = new BufferedInputStream(new 
URL(
                                        
"http://www.faronet.be/files/u16/wikipedia.jpg")
                                        .openStream(), 1024 * 4);
                        OutputStream out = new FileOutputStream(f);
                        byte buf[] = new byte[1024];
                        int len;
                        while ((len = inputStream.read(buf)) > 0)
                                out.write(buf, 0, len);
                        out.close();
                        inputStream.close();
                        System.out.println("\nFile is created");

                        String username="appketttletest";
                        String pass="appkettlE";
                        TwitPic tpRequest = new TwitPic(username,pass);
                        TwitPicResponse tpResponse = null;

                        tpResponse = tpRequest.uploadAndPost(f, "Testing 
twitpic...");
                        System.out.println("user authenticated!!! he he, i dont 
know how");

                } catch (Exception e) {
                        Log.i("error","faliled");
                        e.printStackTrace();
                }
}

--

2. Portrait vs landscape using sensor

Hi,

I'm trying to detect landscape vs portrait orientation with the
following:

  public void onSensorChanged(SensorEvent event) {
      float pitch = event.values[2];
      if (pitch <= 45 && pitch >= -45) {
         // portrait
      }
      else if (pitch < -45) {
         // landscape
      }
      else if (pitch > 45) {
         // landscape
      }
  }

anyone have something more robust? It works pretty well, except if the
phone is in a landscape orientation, and the user starts to 'flatten'
it out, starts thinking it's in the portrait orientation again,

Thanks

-- 

3. AudioTrack stop/release

4. Viamici 鈥?the First Map Cali bration Solution for the Android Platform

5. java access from Android Webkit plugin

6. JetCreator

7. Display Contacts "You don't have any contacts to display" possibly caused by NullPointerException: null