Passing a 2 dimensional array to an Activity

by Zhubham » Wed, 01 Apr 2009 13:55:12 GMT


Sponsored Links
 Hi,

I need to pass a 2 dimensional array to an ACTIVITY  from a SERVICE.
How can I achieve this in minimum number of statements (as in avoiding
putExtras for each and every string stored in the array)??

Please help me with this.

Thanks.

Best Regards,
Zhubham
--~--~---------~--~----~------------~-------~--~----~



Passing a 2 dimensional array to an Activity

by dillirao malipeddi » Wed, 01 Apr 2009 19:11:40 GMT


 you can do in this way also...

Use a static two dimensional array in separate class and use it in service
and activity






-- 
Dilli Rao. M

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Passing a 2 dimensional array to an Activity

by Miguel Paraz » Wed, 01 Apr 2009 20:21:09 GMT


 


Hi,
You could use the JSON en/decoding functions. You can store lists and
maps of Strings. They probably consume more CPU, though.
--~--~---------~--~----~------------~-------~--~----~



Passing a 2 dimensional array to an Activity

by Mark Murphy » Wed, 01 Apr 2009 20:25:07 GMT


 




If the service is in the same process as the activity, you can use the
singleton pattern and have the activity call some method on the service
object.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books.html 

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. nullPointer/thread error when reading contacts

Hi all,
I've been trying to read the contacts list so that I can compare phone
numbers in it against the number on an incomming SMS message.
I've been getting an error that I just can't fix.

The method is:
public String checkContacts(String telNo)
    {
        String[] projection = new String[] {People.NAME, People.NUMBER};
        Uri mContacts = People.CONTENT_URI;
        String selection = People.NUMBER + "=" + telNo;
        String sort = People.NAME + " ASC";

        Cursor managedCursor = managedQuery(mContacts, projection,
selection, null, sort);
        startManagingCursor(managedCursor);

        if(managedCursor.getCount() > 0)
        {
                managedCursor.moveToFirst();
                return managedCursor.getString(0);
        }
        else
        {
                return telNo;
        }
    }

Output from LogCat looks like this:
10-13 16:37:35.966: DEBUG/AndroidRuntime(292): Shutting down VM
10-13 16:37:35.966: WARN/dalvikvm(292): threadid=3: thread exiting
with uncaught exception (group=0x40010e28)
10-13 16:37:35.976: ERROR/AndroidRuntime(292): Uncaught handler:
thread main exiting due to uncaught exception
10-13 16:37:35.996: ERROR/AndroidRuntime(292):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{napier.vallis/napier.vallis.SMSClient}:
java.lang.NullPointerException
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2140)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2156)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.os.Handler.dispatchMessage(Handler.java:88)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.os.Looper.loop(Looper.java:123)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.ActivityThread.main(ActivityThread.java:3742)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
java.lang.reflect.Method.invokeNative(Native Method)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
java.lang.reflect.Method.invoke(Method.java:515)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:739)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
dalvik.system.NativeStart.main(Native Method)
10-13 16:37:35.996: ERROR/AndroidRuntime(292): Caused by:
java.lang.NullPointerException
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.content.ContextWrapper.getContentResolver(ContextWrapper.java:
89)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.Activity.managedQuery(Activity.java:1442)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
napier.vallis.Functions.checkContacts(Functions.java:70)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
napier.vallis.SMSClient.onCreate(SMSClient.java:34)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1122)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2103)
10-13 16:37:35.996: ERROR/AndroidRuntime(292):     ... 11 more

If any further information is needed I can easily post it up.

Any advice or guidance would be greatly appreciated.
Thanks,

V.
--~--~---------~--~----~------------~-------~--~----~

2. Contacts DataBase

I have 2 questions. Do you know why I can't update the contact phone
numbers and how can I read an IM (Instant message) account in the new
version of sdk (v 1.0) ?

-- 
Ing. Alexandru Mos


--~--~---------~--~----~------------~-------~--~----~

3. Android Filesytem loading error on i.mx31 platform

4. how to select text in a TextView?

5. Socket exception-unknown error from HttpClient execute() method

6. How to listen for changes on SMS content provider?

7. One week to go.....