API for changing main menu

by mboehmer » Tue, 10 Feb 2009 19:55:54 GMT


Sponsored Links
 Hi there,

is it possible, to control the icons shown in the main menu and on the
"desktop" of the device by code? Is there an API for adding and
removing icons/applications and for changing the arrangement?

Best regards
mboehmer
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. regarding getting stuff from backend and displaying them as ListView in a Tab

hi,
 i am trying to retrieve records from my mysql database and display
them as a ListView in tabs . I am sending back( to my php script on
the server) a particular value of id and then my php script runs a
query and creates a JSON document, that is sent to me and i then store
it in an arraylist of HashMaps and then by using a SimpleAdapter I am
binding the arraylist to my Listview.

The PROBLEM is that , when i try to do the above mentioned stuff in a
project without tabs, i am able to see the desired result. BUT when i
try and displa the listView like this in a Tab, I am unable to see
anything, the Tab is just blank. Although i can see hard coded
String[] as ListView in my other tabs. I am providing the code for
both of my main project class and the other class that gets the
records and tries to display in on the Tab screen but is unable to do
so. PLEASE help me out -

my main project class -

[CODE]package dev.sh;

import android.app.TabActivity;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class androidtab extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      // setContentView(R.layout.main);

        Resources res = getResources(); //Resource object to get the
drawables (the tab icons here)
        TabHost tab_host = getTabHost(); // the activity TabHost
        TabHost.TabSpec spec;
        Intent intent; // reusable Intent for each tab

        //Creating an Intent to launch an Activity for the tab
        intent = new Intent().setClass(this, AlphaActivity.class);
        spec =
tab_host.newTabSpec("projects").setIndicator("Projects",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
        tab_host.addTab(spec);

        intent = new Intent().setClass(this, BetaActivity.class);
        spec =
tab_host.newTabSpec("tasks").setIndicator("Tasks",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
        tab_host.addTab(spec);

        intent = new Intent().setClass(this, GammaActivity.class);
        spec =
tab_host.newTabSpec("display").setIndicator("Display",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
        tab_host.addTab(spec);

        tab_host.setCurrentTab(1);


    }
}[/CODE]


my other class that tries to get the backend records and display them
as a ListView is -

[CODE]package dev.sh;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class BetaActivity extends ListActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String result = "";

          //the year data to send

          ArrayList<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>();

          nameValuePairs.add(new BasicNameValuePair("task_id","2"));

          ListView lv = getListView();
            lv.setTextFilterEnabled(true);



          //http post

       try{

                 HttpClient httpclient = new DefaultHttpClient();

                  HttpPost httppost = new HttpPost("http://192.168.1.8/
testhttpphp.php");

                  httppost.setEntity(new
UrlEncodedFormEntity(nameValuePairs));

                HttpResponse response = httpclient.execute(httppost);

               HttpEntity entity = response.getEntity();

                  InputStream is = entity.getContent();
               //   FileOutputStream os = new FileOutputStream(file);



          //convert response to string
                  try{

                      BufferedReader reader = new BufferedReader(new
InputStreamReader(is,"iso-8859-1"),8);

                      StringBuilder sb = new StringBuilder();
                        String line = null;
                        while ((line = reader.readLine()) != null) {
                                sb.append(line + "\n");
                        }

                      is.close();



                      result=sb.toString();

              }catch(Exception e){

                      Log.e("log_tag", "Error converting result
"+e.toString());

              }



              //parse json data

              try{

                      JSONArray jArray = new JSONArray(result);

                      List<Map<String, String>> groupData = new
ArrayList<Map<String, String>>();

                    // -- list item hash re-used
                    Map<String, String> group;
                 // -- create record

                      for(int i=0;i<jArray.length();i++){

                              JSONObject json_data =
jArray.getJSONObject(i);

                              group = new HashMap<String, String>();
 
group.put( "name",json_data.getString("name") );
                              groupData.add(group);



                      }//end of for

                      SimpleAdapter adapter = new SimpleAdapter( this,
groupData, android.R.layout.simple_list_item_2,
                              new String[] {"name" },
                              new int[]{ android.R.id.text1} );
                      setListAdapter(adapter);

              }

              catch(JSONException e){

                      Log.e("log_tag", "Error parsing data
"+e.toString());

              }


       }catch(Exception e){

         Log.e("log_tag", "Error in http connection "+e.toString());

 }

}// end of onCreate[/CODE]

please tell me why it doesn't work. also i don't know where can i read
my Log entries. I use an emulator and do not test my app on a device.
i tried running 'adb logcat', it gives me a lot of stuff which doesn't
make sense to me, so is there a way i could see my log as a text file
or something similar?

Thanks in advance






-- 

2. Get all icons positions in wallpaper

How do I get (given it's possible to do) the position of every icon in
the screen, talking about a live wallpaper?
Some array with x and y's??

Hope so :) but how?

Thanks

-- 

3. Playback Raw AAC and BSF H.264

4. CyaSSL SSL Provider for Android Released 鈥?Alpha Version

5. AudioTrack and STREAM_MODE

6. i haz an idea

7. Job Opportunity with very large Wireless Provider