[android-developers] android bug gsm: NetworkOperatorName when returning to home network

2012-05-10 Thread Graham Bright
Hi, 
 
When I roam in another network my android devices books into the GSM 
network of that Operator. The NetworkOperatorName is displayed and all is 
fine. 
 
However when I return to my  home country the network name of the operator 
from the visted country is still present on my android devices 
 
Samsung 10.1n tablet  android version 3.2 
Samsung Galaxy 9000 android version 2.2
 
note: this is not network related I have explored all possibilites there. 
Additionally it is not sim related I have swapped out the sims between 
devices and different devices however same effect.
 
I am sure of a way to reset the network name other than a hard reset of the 
device, however, this is very annoying I loose everything. 
 
I will look into TelephonyManager but I do not expect to find anything 
together with eclipse trace. 
 
Can you help, program wise or other
 
thanks
graham

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] I need a way to get hold of a populated hashmap from a service?

2012-04-11 Thread Graham Bright
Hi,

Would  you suggest using the steps mentioned in the blog below to bind
to a running service? I need a way to get hold of a populated hashmap
from my service?

 bindService(mServiceIntent, mConnection, Context.BIND_AUTO_CREATE);

...

http://www.ozdroid.com/#!BLOG/2010/12/19/How_to_make_a_local_Service_and_bind_to_it_in_Android

Instead of working with and returning a database I would liketo return
a hashmap.

thanks graham

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] SipDroid project + chat or sms

2012-04-06 Thread Graham Bright
Found jainsip to be better not sure if this is enabled voip support on all
handsets

On 6 Apr 2012 15:55, "Jagruti Sangani"  wrote:

hello

can anybody know how can we send message to other sip user in
sipdroid? Or can we  add chat facility in sipdroid like as in viber?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] customAdapter how to print out content of array in TextView.setText() of getview

2012-04-04 Thread Graham Bright
Hi,

I have written a CustomAdapter to display a list of hash key+value
items as a list. But I am stuck on the line below.

label.setText(my_VALUES[0])

Class two is my CustomAdapter and I am passing it a hashMap

public MyCustomAdapter(DynamicLists dynamicLists, int row,
HashMap data)

here I combine key+value pairs and I assign them to an array called
my_VALUES. But I don't know if this is correct?

How can I print out each KEY+VALUE pair as a seperate item in getview.
at the moment I can only use label.setText(my_VALUES[0])

Thanks

graham
package gb.org;


//lists are not checkboxes
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;


//class 1
public class DynamicLists extends ListActivity {



//class 2
public class MyCustomAdapter extends BaseAdapter {
private HashMap mData = new
HashMap();
private String[] mKeys;
String[] my_VALUES = new String[100];



public MyCustomAdapter(DynamicLists dynamicLists, int row,
HashMap data){
mData = data;
mKeys = mData.keySet().toArray(new String[data.size()]);
Log.d(TAG, "INSIDE ADAPTER HELLO WORLD " + map.entrySet());


String[] array = new String[map.size()];
int count = 0;
String combined="";
for(Map.Entry entry : map.entrySet()){
combined="A"+entry.getKey()+"B"+entry.getValue();

my_VALUES[count]=combined;
Log.d(TAG, " my_VALUES " + my_VALUES);
count++;


}


}

@Override
public View getView(int position, View convertView, ViewGroup
parent) {
// TODO Auto-generated method stub
String key = mKeys[position];
String Value = getItem(position).toString();

//do your view stuff here
Log.d(TAG, "inside getview  ");
View row=convertView;

if (row==null){
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.row, null);
}

TextView label =(TextView)row.findViewById(R.id.blocked);
label.setText(my_VALUES[0]);  //printing out the last value

return row;

}
@Override
public int getCount() {

// TODO Auto-generated method stub
return mData.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return mData.get(mKeys[position]);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}


}  //end of class 2



private static final String TAG = "Example";


//class 1


public static  HashMap map = new HashMap();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   //tie data to list, call constructor MyCustomAdapter
   //populate the list. ArrayAdapter takes current class, layout
and array
   map.put("year", "Apple");
   map.put("make", "Mango");
   map.put("model", "Grape");
   map.put("style", "Orange");
   map.put("series", "Peach");
   Log.d(TAG, "HELLO WORLD " + map.entrySet());
   //link to my adapter
   setListAdapter(new MyCustomAdapter(DynamicLists.this,
R.layout.row, map));

}


@Override
protected void onListItemClick(ListView l, View v, int position,
long id) {
// TODO Auto-generated method stub
//super.onListItemClick(l, v, position, id);
String selection = l.getItemAtPosition(position).toString();
Toast.makeText(this, selection, Toast.LENGTH_LONG).show();


}


} //end of class 1






-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] getview in customadapter not called

2012-04-04 Thread Graham Bright
Hi,

In class 1 I have a hashmap which I send to my
CustomAdapter.

   map.put("year", "Apple");
   map.put("make", "Mango");
   map.put("model", "Grape");
   map.put("style", "Orange");
   map.put("series", "Peach");
   Log.d(TAG, "HELLO WORLD " + map.entrySet());
   //link to my adapter
   setListAdapter(new MyCustomAdapter(DynamicLists.this,
R.layout.row, map));


but in class 2 my MyCustomAdapter getView function is not getting
called, can you help understand why ?

thanks

CODE
package gb.org;



import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;


//class 1
public class DynamicLists extends ListActivity {


//class 2
public class MyCustomAdapter extends BaseAdapter {
String my_VALUES;
public MyCustomAdapter(Context context, int
textViewResourceId,HashMap map) {
Log.d(TAG, "HELLO WORLD INSIDE ADAPTER " + map.entrySet());
String[][] array = new String[map.size()][2];
int count = 0;
String combined="";
for(Map.Entry entry : map.entrySet()){
combined=""+entry.getKey()+""+entry.getValue();
count++;
}
my_VALUES = combined;
//iternate over hashmap
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup
parent) {
// TODO Auto-generated method stub
   Log.d(TAG, "inside getview  ");
View row=convertView;

if (row==null){
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.row, null);
}

TextView label =(TextView)row.findViewById(R.id.blocked);
label.setText(my_VALUES);

return row;

}

@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}


@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}


@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
}  //end of class 2







private static final String TAG = "Example";



public static  HashMap map = new HashMap();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   //tie data to list, call constructor MyCustomAdapter
   //populate the list. ArrayAdapter takes current class, layout
and array
   map.put("year", "Apple");
   map.put("make", "Mango");
   map.put("model", "Grape");
   map.put("style", "Orange");
   map.put("series", "Peach");
   Log.d(TAG, "HELLO WORLD " + map.entrySet());
   //link to my adapter
   setListAdapter(new MyCustomAdapter(DynamicLists.this,
R.layout.row, map));


}


@Override
protected void onListItemClick(ListView l, View v, int position,
long id) {
// TODO Auto-generated method stub
//super.onListItemClick(l, v, position, id);
String selection = l.getItemAtPosition(position).toString();
Toast.makeText(this, selection, Toast.LENGTH_LONG).show();



}


} //end of class 1



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] ArrayIndexOutOfBoundsException

2012-04-04 Thread Graham Bright
Hi,

I can't figure out why I am getting and out of bounds exception ? Any
ideas

Thanks

public static String[] items = new String[0];


public static  HashMap map = new HashMap();


@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

//sample values for the hash map
map.put("year", "Apple");
map.put("make", "Mango");
map.put("model", "Grape");
map.put("style", "Orange");
map.put("series", "Peach");

Set entries = map.entrySet();
Iterator entriesIterator = entries.iterator();
int i=0;
String addEntries = "";
while(entriesIterator.hasNext()){

Map.Entry mapping = (Map.Entry) entriesIterator.next();
addEntries="" + mapping.getKey() + "" + mapping.getValue();
items[i] = addEntries;

i++;


}

04-04 10:44:39.615: WARN/dalvikvm(5258): threadid=3: thread exiting
with uncaught exception (group=0x4001dc20)
04-04 10:44:39.615: ERROR/AndroidRuntime(5258): Uncaught handler:
thread main exiting due to uncaught exception
04-04 10:44:39.630: ERROR/AndroidRuntime(5258):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{listmodified.org/listmodified.org.listmodified}:
java.lang.ArrayIndexOutOfBoundsException
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2496)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2512)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.os.Handler.dispatchMessage(Handler.java:99)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.os.Looper.loop(Looper.java:123)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.app.ActivityThread.main(ActivityThread.java:4363)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
java.lang.reflect.Method.invokeNative(Native Method)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
java.lang.reflect.Method.invoke(Method.java:521)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:862)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
dalvik.system.NativeStart.main(Native Method)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): Caused by:
java.lang.ArrayIndexOutOfBoundsException
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
listmodified.org.listmodified.onCreate(listmodified.java:72)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2459)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to creating a custom HashMapAdapter

2012-04-04 Thread Graham Bright
Hi,

If I have a hashmap containing the following how can I instantiate a
custom adapter. The custom adapter should extend baseadapter.

Hashmap contains (String,String)

I need to combine both key and value so it looks something like
"KEY+VALUE", "KEY+VALUE" and assign this to an array VALUES. The
array VALUES is used later on when I insantiate my custom adpter

Instantiation should look something like this



MyCustomAdapter adapter = new MyCustomAdapter(this,
android.R.layout.simple_list_item_1, VALUES);
setListAdapter(adapter)

I am lost here so code would be a big help.

THANKS
graham

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: CAN SOMEONE PLEASE HELP with hashmaps thank you

2012-04-03 Thread Graham Bright
Hi,

So I have something like this now

*

public class listmodified extends ListActivity implements OnGestureListener
{
 //public ArrayList myList = new
ArrayList(Arrays.asList(items));


  public Map myHashMap;

  {

  String Result="";
  myHashMap = new HashMap();
   myHashMap.put(1, "one");
   myHashMap.put(2, "two");

   myHashMap.keySet().toArray();
   myHashMap.values().toArray();


   Result = ": + myHashMap.keySet().toArray() +
myHashMap.values().toArray()";

  }

I probably need to iterate  over the hashmap and populate items with
Result. Items could be declared outside of the brackets as

public static String[] items={};
*

**

On Tue, Apr 3, 2012 at 11:04 PM, Justin Anderson wrote:

> maybe I could use the following to feed the data to an ArrayAdapter
>> from the Hashmap which is declared outside of MyClass not sure if that
>> would work
>>
>> new ArrayList(myHashMap. keySet()), assuming myHashMap is a
>> HashMap.
>>
> Then your ArrayList would only have half the needed data It seemed
> like you needed both the key and the value in the adapter.
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Tue, Apr 3, 2012 at 3:01 PM, Graham Bright wrote:
>
>> maybe I could use the following to feed the data to an ArrayAdapter
>> from the Hashmap which is declared outside of MyClass not sure if that
>> would work
>>
>> new ArrayList(myHashMap.keySet()), assuming myHashMap is a
>> HashMap.
>>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: CAN SOMEONE PLEASE HELP with hashmaps thank you

2012-04-03 Thread Graham Bright
Thanks,

That worked fine fine, I'm new to this stuff :)




maybe I could use the following to feed the data to an ArrayAdapter
from the Hashmap which is declared outside of MyClass not sure if that
would work

new ArrayList(myHashMap.keySet()), assuming myHashMap is a
HashMap.


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] CAN SOMEONE PLEASE HELP with hashmaps thank you

2012-04-03 Thread Graham Bright
private static final Map myHashMap = new HashMap();
static {
 myHashMap.put(1, "one");
 myHashMap.put(2, "two");
}

Sorry I found the problem

thanks

graham


On Tue, Apr 3, 2012 at 10:42 PM, Justin Anderson wrote:

> Can you provide some actual snippets of code... like more than just how
> you are declaring your HashMap?
>
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Tue, Apr 3, 2012 at 2:42 PM, Justin Anderson wrote:
>
>> One more question when I declare a test HashMap it seems only to work as
>>> static private static final Map myHashMap = new
>>> HashMap(); static { myHashMap.put(1, "one");
>>> myHashMap.put(2, "two"); } and I am unable to access the HashMap outside of
>>> the brackets. So new ArrayList(MyHashMap.KeySet()) fails as
>>> MyHashMap cannot be resolved ... ?
>>>
>> What?
>>
>>
>> Thanks,
>> Justin Anderson
>> MagouyaWare Developer
>> http://sites.google.com/site/magouyaware
>>
>>
>> On Tue, Apr 3, 2012 at 2:37 PM, Graham Bright 
>> wrote:
>>
>>> One more question when I declare a test HashMap it seems only to work as
>>> static private static final Map myHashMap = new
>>> HashMap(); static { myHashMap.put(1, "one");
>>> myHashMap.put(2, "two"); } and I am unable to access the HashMap outside of
>>> the brackets. So new ArrayList(MyHashMap.KeySet()) fails as
>>> MyHashMap cannot be resolved ... ?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-developers@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> android-developers+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>>
>>
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] CAN SOMEONE PLEASE HELP with hashmaps thank you

2012-04-03 Thread Graham Bright
One more question when I declare a test HashMap it seems only to work as
static private static final Map myHashMap = new
HashMap(); static { myHashMap.put(1, "one");
myHashMap.put(2, "two"); } and I am unable to access the HashMap outside of
the brackets. So new ArrayList(MyHashMap.KeySet()) fails as
MyHashMap cannot be resolved ... ?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] CAN SOMEONE PLEASE HELP with hashmaps thank you

2012-04-03 Thread Graham Bright
Thanks Justin,

I'll give that a go.

graham

On Tue, Apr 3, 2012 at 9:56 PM, Justin Anderson wrote:

> When you need to update the adapter, iterate over your hash map and insert
> all the data into a list.  Maybe do something like this:
>
> 1) Create a DataPairs class:
>
> public class DataPairs
> {
>  public String _key;
>  public String _value;
>
>  public DataPairs(String key, String val)
>  {
>   _key = key;
>  _value = val;
>  }
> }
>
> 2) Create a new list of DataPairs objects, iterate over your hash map, and
> insert the data into your list
> 3) Update your adapter with the new list of data and call
> notifyDataSetChanged()
>
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Tue, Apr 3, 2012 at 1:46 PM, Graham Bright wrote:
>
>> Thanks Justin,
>>
>> Order is not important, as my end goal is to present to the user a simple
>> list of values + keys. When the user longclicks on an item it will be
>> deleted from the hash.
>>
>> What would you suggest?
>>
>> graham
>>
>>
>>
>>
>> On Tue, Apr 3, 2012 at 9:24 PM, Justin Anderson wrote:
>>
>>> Keep in mind that HashMap does not have an order...  ArrayAdapter does
>>> everything based on a position value, which indicates an ordered collection
>>> of some sort.
>>>
>>> Thanks,
>>> Justin Anderson
>>> MagouyaWare Developer
>>> http://sites.google.com/site/magouyaware
>>>
>>>
>>> On Tue, Apr 3, 2012 at 1:16 PM, Graham Bright 
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I have a hashmap with key, value pairs example :-
>>>>
>>>> (msisdn,value)
>>>>
>>>> 43664xxx,2
>>>> 43665xxx,3
>>>>
>>>> now I want to display this information in a ListView but I don't know
>>>> how to feed the data to an ArrayAdapter.
>>>>
>>>> HERE IS MY ADAPTER, note I want to replace myList with data from the
>>>> Hashmap a concatentated key+value.
>>>>
>>>> 1. Pass the above hashmap as an adapter, replacing myList with the
>>>> hashmap
>>>>
>>>> adapter=new
>>>> ArrayAdapter(this,android.R.layout.simple_list_item_1,myList);
>>>>setListAdapter(adapter);
>>>>
>>>> Note this is what I have without using the hashmap
>>>>
>>>> THANKS IN ADVANCE
>>>>
>>>>
>>>> package listmodified.org;
>>>>
>>>> import java.util.Arrays;
>>>> import java.util.ArrayList;
>>>> import java.util.HashMap;
>>>> import java.util.List;
>>>> import java.util.Map;
>>>>
>>>> import android.app.ListActivity;
>>>> import android.os.Bundle;
>>>> import android.os.Handler;
>>>> import android.os.Message;
>>>> import android.view.View;
>>>> import android.widget.AdapterView;
>>>> import android.widget.ArrayAdapter;
>>>> import android.widget.ListView;
>>>> import android.widget.TextView;
>>>> import android.widget.AdapterView.OnItemLongClickListener;
>>>> import android.view.GestureDetector.OnGestureListener;
>>>> import android.view.GestureDetector;
>>>> import android.view.MotionEvent;
>>>> import android.widget.Toast;
>>>>
>>>>
>>>>
>>>>
>>>> public class listmodified extends ListActivity implements
>>>> OnGestureListener {
>>>>public ArrayList myList = new
>>>> ArrayList(Arrays.asList(items));
>>>>private TextView selection;  //  MAIN.xml
>>>>public ArrayAdapter adapter; // my adapter
>>>>public OnItemLongClickListener itemDelListener;
>>>>private GestureDetector gestureScanner;
>>>>public int longClickedItem = 0;  //check if longClick is
>>>> selected or
>>>> not
>>>>private String itemSelected; // for delete function
>>>>private static final byte UPDATE_LIST = 100;
>>>>public AdapterView parent; //used by OnLitemLongClickListener
>>>>public int position;
>>>>
>>>>//tie items to an array list called myList
>>>>public static  String[] items={"lorem"

Re: [android-developers] CAN SOMEONE PLEASE HELP with hashmaps thank you

2012-04-03 Thread Graham Bright
Thanks Justin,

Order is not important, as my end goal is to present to the user a simple
list of values + keys. When the user longclicks on an item it will be
deleted from the hash.

What would you suggest?

graham




On Tue, Apr 3, 2012 at 9:24 PM, Justin Anderson wrote:

> Keep in mind that HashMap does not have an order...  ArrayAdapter does
> everything based on a position value, which indicates an ordered collection
> of some sort.
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Tue, Apr 3, 2012 at 1:16 PM, Graham Bright wrote:
>
>> Hi,
>>
>> I have a hashmap with key, value pairs example :-
>>
>> (msisdn,value)
>>
>> 43664xxx,2
>> 43665xxx,3
>>
>> now I want to display this information in a ListView but I don't know
>> how to feed the data to an ArrayAdapter.
>>
>> HERE IS MY ADAPTER, note I want to replace myList with data from the
>> Hashmap a concatentated key+value.
>>
>> 1. Pass the above hashmap as an adapter, replacing myList with the
>> hashmap
>>
>> adapter=new
>> ArrayAdapter(this,android.R.layout.simple_list_item_1,myList);
>>setListAdapter(adapter);
>>
>> Note this is what I have without using the hashmap
>>
>> THANKS IN ADVANCE
>>
>>
>> package listmodified.org;
>>
>> import java.util.Arrays;
>> import java.util.ArrayList;
>> import java.util.HashMap;
>> import java.util.List;
>> import java.util.Map;
>>
>> import android.app.ListActivity;
>> import android.os.Bundle;
>> import android.os.Handler;
>> import android.os.Message;
>> import android.view.View;
>> import android.widget.AdapterView;
>> import android.widget.ArrayAdapter;
>> import android.widget.ListView;
>> import android.widget.TextView;
>> import android.widget.AdapterView.OnItemLongClickListener;
>> import android.view.GestureDetector.OnGestureListener;
>> import android.view.GestureDetector;
>> import android.view.MotionEvent;
>> import android.widget.Toast;
>>
>>
>>
>>
>> public class listmodified extends ListActivity implements
>> OnGestureListener {
>>public ArrayList myList = new
>> ArrayList(Arrays.asList(items));
>>private TextView selection;  //  MAIN.xml
>>public ArrayAdapter adapter; // my adapter
>>public OnItemLongClickListener itemDelListener;
>>private GestureDetector gestureScanner;
>>public int longClickedItem = 0;  //check if longClick is selected
>> or
>> not
>>private String itemSelected; // for delete function
>>private static final byte UPDATE_LIST = 100;
>>public AdapterView parent; //used by OnLitemLongClickListener
>>public int position;
>>
>>//tie items to an array list called myList
>>public static  String[] items={"lorem", "ipsum", "dolor",
>>"sit", "amet",
>>"consectetuer", "adipiscing", "elit", "morbi", "vel",
>>"ligula", "vitae", "arcu", "aliquet", "mollis",
>>"etiam", "vel", "erat", "placerat", "ante",
>>"porttitor", "sodales", "pellentesque", "augue", "purus"};
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>@Override
>>public void onCreate(Bundle icicle) {
>>super.onCreate(icicle);
>>
>>OnItemLongClickListener itemDelListener = new
>> OnItemLongClickListener(){
>>
>>//@Override
>>public boolean onItemLongClick(AdapterView parent, View
>> arg1,
>>int position, long arg3) {
>>// TODO Auto-generated method stub
>>
>>  itemSelected=parent.getItemAtPosition(position).toString();
>>adapter.remove(itemSelected);
>>Toast.makeText(listmodified.this, "position is:" +
>> position,
>> Toast.LENGTH_SHORT).show();
>>myList.remove(this);  //remove the current object
>> , position throws
>> an exception
>>adapter.notifyDataSetChanged();
>>
>>
>>return false;
>>}};
>>
>>setContentView(R.layout.main

[android-developers] CAN SOMEONE PLEASE HELP with hashmaps thank you

2012-04-03 Thread Graham Bright
Hi,

I have a hashmap with key, value pairs example :-

(msisdn,value)

43664xxx,2
43665xxx,3

now I want to display this information in a ListView but I don't know
how to feed the data to an ArrayAdapter.

HERE IS MY ADAPTER, note I want to replace myList with data from the
Hashmap a concatentated key+value.

1. Pass the above hashmap as an adapter, replacing myList with the
hashmap

adapter=new
ArrayAdapter(this,android.R.layout.simple_list_item_1,myList);
setListAdapter(adapter);

Note this is what I have without using the hashmap

THANKS IN ADVANCE


package listmodified.org;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.Toast;




public class listmodified extends ListActivity implements
OnGestureListener {
public ArrayList myList = new
ArrayList(Arrays.asList(items));
private TextView selection;  //  MAIN.xml
public ArrayAdapter adapter; // my adapter
public OnItemLongClickListener itemDelListener;
private GestureDetector gestureScanner;
public int longClickedItem = 0;  //check if longClick is selected or
not
private String itemSelected; // for delete function
private static final byte UPDATE_LIST = 100;
public AdapterView parent; //used by OnLitemLongClickListener
public int position;

//tie items to an array list called myList
public static  String[] items={"lorem", "ipsum", "dolor",
"sit", "amet",
"consectetuer", "adipiscing", "elit", "morbi", "vel",
"ligula", "vitae", "arcu", "aliquet", "mollis",
"etiam", "vel", "erat", "placerat", "ante",
"porttitor", "sodales", "pellentesque", "augue", "purus"};









@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

OnItemLongClickListener itemDelListener = new
OnItemLongClickListener(){

//@Override
public boolean onItemLongClick(AdapterView parent, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub

itemSelected=parent.getItemAtPosition(position).toString();
adapter.remove(itemSelected);
Toast.makeText(listmodified.this, "position is:" + 
position,
Toast.LENGTH_SHORT).show();
myList.remove(this);  //remove the current object , 
position throws
an exception
adapter.notifyDataSetChanged();


return false;
}};

setContentView(R.layout.main);


//DEFINE MY OWN VIEW TIE  TO ARRAYLIST myList WHICH CONTAINS STRINGS
adapter=new
ArrayAdapter(this,android.R.layout.simple_list_item_1,myList);
setListAdapter(adapter);

//A VIEW OF THE LIST NECESSARY FOR DELETION

selection=(TextView)findViewById(R.id.selection);


// PART OF LONG CLICK SELECTED CODE
// CALLS IMPLEMENTED METHODS - detect gestures checking my list items
gestureScanner = new GestureDetector(this);
getListView().setOnTouchListener(new View.OnTouchListener() {
  @Override
public boolean onTouch(View v, MotionEvent event) {
return gestureScanner.onTouchEvent(event);
}
});

//UPDATE VIEW DELETE WHEN ONLONG CLICK IS PRESSED
getListView().setOnItemLongClickListener(itemDelListener);

}


//LIST ITEM PRESS CHECKING
public void onListItemClick(ListView parent, View v,
int position, long id){
selection.setText(myList.get(position));
//check to see if LONGCLICK IS PRESSED
if (longClickedItem != -1) {
 Toast.makeText(listmodified.this, "A short click detected",
Toast.LENGTH_SHORT).show();

}
longClickedItem=0;
}

//IMPLEMENTED BY GESTURE
@Override
public boolean onDown(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}


@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX,
float velocityY) {
// TODO Auto-generated method stub
return false;
}


//CHECKS ONLONGPRESS EVENTS SET LONG PRESS TO -1,
//COOL I CAN USE THIS TO SEE IF A LONG CLICK WAS SELECTED LATER ON

 

Re: [android-developers] Re: SIP Stack registration packet with authorization

2012-03-19 Thread Graham Bright
Might be better off using Jain Sipp sipmanager seems not to be supported on
2.3 android phones such as samsung galaxy s and s2

On 14 Mar 2012 15:36, "Nikolay Elenkov"  wrote:

On Thu, Mar 15, 2012 at 12:20 AM, matej148  wrote:
> Hi Nikolay, thank you ...
Maybe it does, but your current configuration seems to be
incompatible with Android. You could try to change or
customize it a bit to make it compatible, if possible.


> Could you recommend us good SIP stack for Android
> 2.3.3 please? We tried J-SIP (works for creat...
The reasons for the conversion error could range from an incorrect
project configuration, to a Java library incompatible with Android.
You might want to check the full message/trace, etc.


> NGN stack (good for 2.1 android app).
If it works on 2.1, it should work on 2.3 as well.

I've only used the native stack, so not very familiar
with other libraries. You might want to look into
siproid, if you are OK with GPL:

http://code.google.com/p/sipdroid/


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" ...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Native SIP Supported on all ICS Devices?

2011-12-30 Thread Graham Bright
Hi,

Is there a tutorial on how to integrate and develop using pjsip  and
eclipse.

thanks

Graham

On Thu, Dec 29, 2011 at 11:08 PM, Shaun  wrote:

> Thanks for the reply, that's the direction I am looking at going now,
> CSipSimple has an API as well so that might make things easy, but I
> would much rather use the native SIP stack Google built in, I think
> this is all a carrier issue.
>
> On Dec 29, 6:06 am, Mukesh Srivastav  wrote:
> > Hi Shaun,
> >
> > I would like to share my experience with SIP Based application on
> Android.
> > I never used the build in api's out of it.
> >
> > I had successfully integrated pjsip of CSipsimple open source and it is
> > working great for me.
> >
> > http://www.pjsip.org/apps.htm
> >
> > Warm Regards,
> > *Mukesh Kumar*,
> > Android Consultant/Freelancer,
> > India,Hyderabad.
> >
> > On Thu, Dec 29, 2011 at 7:10 PM, Graham Bright  >wrote:
>  >
> >
> >
> >
> >
> >
> >
> >
> >
> > > Hi,
> > > I have been playing around with the sipdemo and I have created simple
> > > application. The
> > > application creates SIPManager object and attempts to connect using
> > > SipProfile to sip2sip.info.
> >
> > > This doesn't work either from the phone  (Samsung Galaxy 2 running 2.3
> > > Android) or the emulator.
> >
> > >  I get back sip manager not supported, voip not supported in toast
> > > message.
> >
> > > Does anyone know how the library would be disabled on phones by an
> > > operator, or what I think the phone vendor?
> >
> > > The support of SIP is important for next genration handsets. ( google
> IMS)
> > > Without such stuff like LTE and IMS style applications will be limited
> to
> > > appliacations running on PCs such as a broadband access cllient.
> >
> > > Cheers,
> >
> > > Graham
> >
> > > package gb.org;
> >
> > > import java.text.ParseException;
> >
> > > import android.app.Activity;
> > > import android.net.sip.*;
> > > import android.os.Bundle;
> > > import android.util.Log;
> > > import android.widget.EditText;
> > > import android.widget.Toast;
> >
> > > public class gbsip extends Activity {
> >
> > >public SipManager manager = null;
> > > public SipProfile me = null;
> >
> > >//temporary sip settings
> > >public String name = "gbwien";
> > >public String domain = "sip2sip.info";
> > >public String password = "h7eefbtcff";
> >
> > >/** Called when the activity is first created. */
> > >@Override
> > >public void onCreate(Bundle savedInstanceState) {
> > >super.onCreate(savedInstanceState);
> > >setContentView(R.layout.main);
> >
> > >//this.apiSupport = (EditText) findViewById(R.id.api);
> > >//this.voipSupported = (EditText) findViewById(R.id.voip);
> >
> > >initializeManager();
> > >}
> >
> > >//CREATE A NEW SIP MANAGER INSTANCE
> > >public void initializeManager() {
> > >if(manager == null) {
> > >  manager = SipManager.newInstance(this);
> > > Toast.makeText(gbsip.this,  "Manager supported " +
> > > manager.isApiSupported(this), Toast.LENGTH_LONG).show();
> > > Toast.makeText(gbsip.this,  "VOIP supported " +
> > > manager.isVoipSupported(this), Toast.LENGTH_LONG).show();
> >
> > >}
> > >initializeLocalProfile();
> >
> > >}
> > >//LOG INTO SIP ACCOUNT USING A SIP PROFILE LOCAL TO THE
> > >//DEVICE
> >
> > >public void initializeLocalProfile() {
> > >if (manager == null) {
> > >Toast.makeText(gbsip.this, "manager is null  ",
> > > Toast.LENGTH_LONG).show();
> > >return;
> >
> > >}
> >
> > >if (me != null) {
> > >closeLocalProfile();
> > >}
> >
> > >try {
> >
> > >SipProfile.Builder builder = new
> > > SipProfile.Builder(name, domain);
> > >builder.setPassword(password);
> > >   

Re: [android-developers] Native SIP Supported on all ICS Devices?

2011-12-29 Thread Graham Bright
Hi,
I have been playing around with the sipdemo and I have created simple
application. The
application creates SIPManager object and attempts to connect using
SipProfile to sip2sip.info.

This doesn't work either from the phone  (Samsung Galaxy 2 running 2.3
Android) or the emulator.

 I get back sip manager not supported, voip not supported in toast message.

Does anyone know how the library would be disabled on phones by an
operator, or what I think the phone vendor?

The support of SIP is important for next genration handsets. ( google IMS)
Without such stuff like LTE and IMS style applications will be limited to
appliacations running on PCs such as a broadband access cllient.



Cheers,


Graham

package gb.org;

import java.text.ParseException;


import android.app.Activity;
import android.net.sip.*;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;

public class gbsip extends Activity {


   public SipManager manager = null;
public SipProfile me = null;


   //temporary sip settings
   public String name = "gbwien";
   public String domain = "sip2sip.info";
   public String password = "h7eefbtcff";





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



   //this.apiSupport = (EditText) findViewById(R.id.api);
   //this.voipSupported = (EditText) findViewById(R.id.voip);

   initializeManager();
   }

   //CREATE A NEW SIP MANAGER INSTANCE
   public void initializeManager() {
   if(manager == null) {
 manager = SipManager.newInstance(this);
Toast.makeText(gbsip.this,  "Manager supported " +
manager.isApiSupported(this), Toast.LENGTH_LONG).show();
Toast.makeText(gbsip.this,  "VOIP supported " +
manager.isVoipSupported(this), Toast.LENGTH_LONG).show();

   }
   initializeLocalProfile();

   }
   //LOG INTO SIP ACCOUNT USING A SIP PROFILE LOCAL TO THE
   //DEVICE

   public void initializeLocalProfile() {
   if (manager == null) {
   Toast.makeText(gbsip.this, "manager is null  ",
Toast.LENGTH_LONG).show();
   return;

   }

   if (me != null) {
   closeLocalProfile();
   }


   try {

   SipProfile.Builder builder = new
SipProfile.Builder(name, domain);
   builder.setPassword(password);
   me = builder.build();
   Toast.makeText(gbsip.this, "SIP Registration
successful  ",
Toast.LENGTH_LONG).show();

   // Otherwise the methods aren't guaranteed
to fire.

   manager.setRegistrationListener(me.getUriString(), new
SipRegistrationListener() {
   public void onRegistering(String localProfileUri)
{
   Toast.makeText(gbsip.this, "Registrating with
SIP Server ", Toast.LENGTH_LONG).show();
   }

   public void onRegistrationDone(String
localProfileUri, long expiryTime) {
   Toast.makeText(gbsip.this, "Ready ",
Toast.LENGTH_LONG).show();
   }
   public void onRegistrationFailed(String
localProfileUri, int errorCode,
   String errorMessage) {
   Toast.makeText(gbsip.this, "SIP Registration
error  ", Toast.LENGTH_LONG).show();
   }
   });

   } catch (ParseException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   Toast.makeText(gbsip.this, "SIP Registration
error  ",
Toast.LENGTH_LONG).show();
   } catch (SipException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   Toast.makeText(gbsip.this, "SIP Exception
has occurred  ",
Toast.LENGTH_LONG).show();
   }


   }

   //END OF initializeLocalProfile
   public void closeLocalProfile() {
   if (manager == null) {
   return;
   }
   try {
   if (me != null) {
   manager.close(me.getUriString());
   }
   } catch (Exception ee) {
   Log.d("failed ", "Failed to close local profile.",
ee);
   }
   }



}

Manifest


http://schemas.android.com/apk/res/android";
 package="gb.org"
 android:versionCode="1"
 android:versionName="1.0">


   
   
   
   
   
   
   
   
   
   
   
   
   
   


On Wed,

Re: [android-developers] which to use shared preferences or files best practices

2011-12-24 Thread Graham Bright
Thanks

Graham

On 23 Dec 2011 13:51, "TreKing"  wrote:

On Fri, Dec 23, 2011 at 4:15 AM, Graham Bright 
wrote:
>
> To store the te...
How long is this string? If it's relatively short, a preference. If it's
relatively long, a file.

-
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

 --
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] which to use shared preferences or files best practices

2011-12-23 Thread Graham Bright
Hi all,

I am trying to decide if I should use shared preferences or files for
the following scenario.

I want to present to the user a list of simple text strings which if
selected will be used later in my code.

Example

  Text string 1
  Text string 2
  User defined Text string

If the user selects Text string 1 then this is used later on. A user
may also define his/her own text string for later use.

To store the text strings what would you recommend? A key/value pair
using maybe ListPreferences or maybe text files.

Thanks in advance, I hope the question is not too silly.

Seasons Greetings

Graham

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: PLEASE HELP . java.lang.NullPointerException when Service uses ArrayList

2011-11-25 Thread Graham Bright
Thanks for the great advice, I figured out the problem. I had an issue with
array initialization, and my thread was doing nothing
On Nov 25, 2011 8:06 a.m., "Lew"  wrote:

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: PLEASE HELP . java.lang.NullPointerException when Service uses ArrayList

2011-11-24 Thread Graham Bright
Guys thanks a million I got it working. I can post the code if anyone is
interested?

On 24 Nov 2011 18:52, "Lew"  wrote:

 BelvCompSvs wrote:
>
> I'm just here to confirm what the other two coders told you ~ I found
> it o...
That's actually pretty bad advice.  Don't place a 'catch (Throwable ...)'
around anything.



>
> java:62) and look at line 62 in MyService but before you even try that

That's actually pretty good advice.  Take a look at line 62.  (I wonder why
you didn't identify that line for us, seeing as how you're asking for help)



> do Object someObject= ((val=null)?("error"):(val)) all over code as

Huh?  I don't even understand this advice, much less endorse it.  However,
every interpretation I put on this advice leads to a really bad idea, so
I'm going to suggest that whatever this advice means, you should not follow
it.

What you /should/ do is make sure that references point to something other
than 'null' before you try to dereference them.



>
> what you are looking for is a result of many design types telling
> people that code handles ...
What?

Maybe if there were some punctuation, capital letters, and complete
sentences in there I could understand what this guys is suggesting.



> when you do, fix it some way.

I agree with this advice, which boils down to the oh-so-insightful
suggestion that "analyze the problem, determine a solution!"  That's good
advice, and I'm sure you'll find it exceedingly helpful.

Not.

NullPointerExceptions, like other RuntimeExceptions, are a result of
programmer error, in this case yours.  It means that you have a pointer
still pointing to 'null', but you tried to use it as if it pointed to
something not 'null'.  You have to assign your pointers to something not
'null', and you have to check your pointers before dereferencing them to
make sure they aren't 'null'.

As stated upthread, the stack trace (plus my hint) will tell you which
pointer was pointing to 'null' when you tried to dereference it.

-- 
Lew



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers"...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: PLEASE HELP . java.lang.NullPointerException when Service uses ArrayList

2011-11-23 Thread Graham Bright
Hi I am getting FATAL EXCEPTION when the ArrayList items is
populated;

can you help ?

Thanks
Graham


W/dalvikvm(11235): threadid=9: thread exiting with uncaught exception
(group=0x4
001e578)
E/AndroidRuntime(11235): FATAL EXCEPTION: Thread-10
E/AndroidRuntime(11235): java.lang.NullPointerException
E/AndroidRuntime(11235):at
com.example.MyService.print_result(MyService.
java:62)
E/AndroidRuntime(11235):at com.example.MyService
$1.run(MyService.java:54
)
E/AndroidRuntime(11235):at java.lang.Thread.run(Thread.java:
1019)
W/ActivityManager( 2696):   Force finishing activity
com.example/.ServicesDemo
I/OrientationDebug( 2696): [pwm] in updateOrientationListenerLp()
V/OrientationDebug( 2696): in updateOrientationListenerLp(), Screen
status=true,
 current orientation=1, SensorEnabled=true
I/OrientationDebug( 2696): [pwm] needSensorRunningLp(), return true #4
I/Launcher( 2852): onResume(). mIsNewIntent : false screenOff: false
E/( 2696): Dumpstate > /data/log/dumpstate_app_error
I/dumpstate(11275): begin
D/KeyguardViewMediator( 2696): handleTimeout
W/PowerManagerService( 2696): Timer 0x3->0x3|0x3


package com.example;


import java.util.ArrayList;

import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service {

ArrayList items = null;

public String ORIG = "";
private static final String TAG = "MyService";
public Bundle data = new Bundle();


@Override
public IBinder onBind(Intent intent) {
return null;
}


public static String getTag() {
return TAG;
}


@Override
public void onCreate() {
Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show();

}

@Override
public void onDestroy() {
Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show();
Log.d(TAG, "onDestroy");

}

@Override
public void onStart(Intent intent, int startid) {
Log.d(TAG, "onStart");
data = intent.getExtras();
ORIG = data.getString("originator");
Log.d(TAG, "onCreate");
Thread initBkgdThread = new Thread(new Runnable() {
public void run() {
print_result(ORIG);
}
});
initBkgdThread.start();
}

public void print_result(String orig){
Log.d(TAG, "HELLO WORLD:" + orig);
items.add(orig);
if (items != null) {
items.add(orig);
String toadd = orig.toString();

if(items.contains(toadd)){
Log.d(TAG, "Element already exists exiting ");
} else {
Log.d(TAG, "Adding Element");
items.add(toadd);

}

}
else {
Log.d(TAG, "IS NULL");
}
}

}

On 23 Nov., 12:53, Kostya Vasilyev  wrote:
> Look below "caused by" in the logcat to identify where the
> NullPointerException occurrs. Then fix it.
>
> 23 ноября 2011 г. 15:36 пользователь Graham Bright 
>
>
> > написал:
> > Can anyone help?
>
> > Thanks
> > Graham
> > On Nov 23, 2011 11:51 a.m., "Graham Bright" 
> > wrote:
>
> >> Hi,
>
> >> I am creating service which will run in the background and contain a
> >> blocking list  (implemented using ArrayList) which may be used later
> >> by other activites.
>
> >> My Problem:-
>
> >> From my activity Services Demo I pass data to my service using
>
> >> dataIntent.putExtra("originator", x);
>
> >> this is fine but when I try to store this data in my Service in an
> >> ArrayList called Items I get an exception and I cannot figure out
> >> why.
>
> >> The problem is in my Service code MyService :
>
> >>                if(items.contains(ORIG)){
> >>                        Log.d(TAG, "Element already exists exiting ");
> >>                } else {
> >>                        Log.d(TAG, "Adding Element");
> >>                    items.add(ORIG);
>
> >>                }
> >> Please help.
>
> >> EXCEPTION
> >> java.lang.RuntimeException: Unable to start service .. with
> >> intent
>
> >> caused by: java.lang.NullPointerException
>
> >> Best Regards,
>
> >> Graham
>
> >> CODE Eclipse
>
> >> Activity -> ServicesDemo
> >> Service -> MyService
>
> >> ACTIVITY ServicesDemo
>
> >> package com.example;
>
> >> import android.app.Activity;
> >> import android.content.Intent;
> >> import android.os.Bundle;
> >> import android.util.Log;
> >> import android.view.View;
> >> import android.view.View.OnClickListener;
> >> import android.widget.Button;
> >> import android.widget.EditText;
>
> >> public class ServicesDemo extends Activity implements OnClickListen

[android-developers] Re: PLEASE HELP . java.lang.NullPointerException when Service uses ArrayList

2011-11-23 Thread Graham Bright
Can anyone help?

Thanks
Graham
On Nov 23, 2011 11:51 a.m., "Graham Bright" 
wrote:

> Hi,
>
> I am creating service which will run in the background and contain a
> blocking list  (implemented using ArrayList) which may be used later
> by other activites.
>
> My Problem:-
>
>
> From my activity Services Demo I pass data to my service using
>
> dataIntent.putExtra("originator", x);
>
> this is fine but when I try to store this data in my Service in an
> ArrayList called Items I get an exception and I cannot figure out
> why.
>
> The problem is in my Service code MyService :
>
>if(items.contains(ORIG)){
>Log.d(TAG, "Element already exists exiting ");
>} else {
>Log.d(TAG, "Adding Element");
>items.add(ORIG);
>
>}
> Please help.
>
> EXCEPTION
> java.lang.RuntimeException: Unable to start service .. with
> intent
>
> caused by: java.lang.NullPointerException
>
> Best Regards,
>
> Graham
>
> CODE Eclipse
>
> Activity -> ServicesDemo
> Service -> MyService
>
> ACTIVITY ServicesDemo
>
> package com.example;
>
> import android.app.Activity;
> import android.content.Intent;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.View;
> import android.view.View.OnClickListener;
> import android.widget.Button;
> import android.widget.EditText;
>
> public class ServicesDemo extends Activity implements OnClickListener
> {
>  private static final String TAG = "ServicesDemo";
>  Button buttonStart, buttonStop;
>  EditText Input;
>  String x = "";  //test pass to my service
>
>  @Override
>  public void onCreate(Bundle savedInstanceState) {
>super.onCreate(savedInstanceState);
>setContentView(R.layout.main);
>
>buttonStart = (Button) findViewById(R.id.buttonStart);
>buttonStop = (Button) findViewById(R.id.buttonStop);
>Input = (EditText) findViewById(R.id.INPUT);
>buttonStart.setOnClickListener(this);
>buttonStop.setOnClickListener(this);
>
>  }
>
>  public void onClick(View src) {
>switch (src.getId()) {
>case R.id.buttonStart:
>  Log.d(TAG, "onClick: starting srvice");
>  Intent dataIntent = new Intent(ServicesDemo.this,
> MyService.class);
>  x = Input.getText().toString();
>  dataIntent.putExtra("originator", x);
>  startService(dataIntent);
>
>  break;
>
>case R.id.buttonStop:
>
>  Log.d(TAG, "onClick: stopping srvice");
>  //implicit starting
>  stopService(new Intent(this, MyService.class));
>  break;
>}
>  }
>
>
> public static String getTag() {
>return TAG;
> }
> }
> ---
>
>
> --Service MyService -
> package com.example;
>
>
> import java.util.ArrayList;
>
> import android.app.Service;
> import android.content.Intent;
> import android.os.Bundle;
> import android.os.IBinder;
> import android.util.Log;
> import android.widget.Toast;
>
> public class MyService extends Service {
>
>ArrayList items;
>
>public String ORIG = "";
>private static final String TAG = "MyService";
>public Bundle data = new Bundle();
>
>
>@Override
>public IBinder onBind(Intent intent) {
>return null;
>}
>
>
>public static String getTag() {
>return TAG;
>}
>
>
>@Override
>public void onCreate() {
>Toast.makeText(this, "My Service Created",
> Toast.LENGTH_LONG).show();
>Log.d(TAG, "onCreate");
>
>
>}
>
>@Override
>public void onDestroy() {
>Toast.makeText(this, "My Service Stopped",
> Toast.LENGTH_LONG).show();
>Log.d(TAG, "onDestroy");
>
>}
>
>@Override
>public void onStart(Intent intent, int startid) {
>Log.d(TAG, "onStart");
>data = intent.getExtras();
>ORIG = data.getString("originator");
>Toast.makeText(this, "My Service Started with passed in
> value " +
> ORIG, Toast.LENGTH_LONG).show();
>if(items.contains(ORIG)){
>Log.d(TAG, "Element already exists exiting ");
>} else {
>Log.d(TAG, "Adding Element");

[android-developers] PLEASE HELP . java.lang.NullPointerException when Service uses ArrayList

2011-11-23 Thread Graham Bright
Hi,

I am creating service which will run in the background and contain a
blocking list  (implemented using ArrayList) which may be used later
by other activites.

My Problem:-


>From my activity Services Demo I pass data to my service using

dataIntent.putExtra("originator", x);

this is fine but when I try to store this data in my Service in an
ArrayList called Items I get an exception and I cannot figure out
why.

The problem is in my Service code MyService :

if(items.contains(ORIG)){
Log.d(TAG, "Element already exists exiting ");
} else {
Log.d(TAG, "Adding Element");
items.add(ORIG);

}
Please help.

EXCEPTION
java.lang.RuntimeException: Unable to start service .. with
intent

caused by: java.lang.NullPointerException

Best Regards,

Graham

CODE Eclipse

Activity -> ServicesDemo
Service -> MyService

ACTIVITY ServicesDemo

package com.example;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ServicesDemo extends Activity implements OnClickListener
{
  private static final String TAG = "ServicesDemo";
  Button buttonStart, buttonStop;
  EditText Input;
  String x = "";  //test pass to my service

  @Override
  public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

buttonStart = (Button) findViewById(R.id.buttonStart);
buttonStop = (Button) findViewById(R.id.buttonStop);
Input = (EditText) findViewById(R.id.INPUT);
buttonStart.setOnClickListener(this);
buttonStop.setOnClickListener(this);

  }

  public void onClick(View src) {
switch (src.getId()) {
case R.id.buttonStart:
  Log.d(TAG, "onClick: starting srvice");
  Intent dataIntent = new Intent(ServicesDemo.this,
MyService.class);
  x = Input.getText().toString();
  dataIntent.putExtra("originator", x);
  startService(dataIntent);

  break;

case R.id.buttonStop:

  Log.d(TAG, "onClick: stopping srvice");
  //implicit starting
  stopService(new Intent(this, MyService.class));
  break;
}
  }


public static String getTag() {
return TAG;
}
}
---


--Service MyService -
package com.example;


import java.util.ArrayList;

import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service {

ArrayList items;

public String ORIG = "";
private static final String TAG = "MyService";
public Bundle data = new Bundle();


@Override
public IBinder onBind(Intent intent) {
return null;
}


public static String getTag() {
return TAG;
}


@Override
public void onCreate() {
Toast.makeText(this, "My Service Created",
Toast.LENGTH_LONG).show();
Log.d(TAG, "onCreate");


}

@Override
public void onDestroy() {
Toast.makeText(this, "My Service Stopped",
Toast.LENGTH_LONG).show();
Log.d(TAG, "onDestroy");

}

@Override
public void onStart(Intent intent, int startid) {
Log.d(TAG, "onStart");
data = intent.getExtras();
ORIG = data.getString("originator");
Toast.makeText(this, "My Service Started with passed in value " 
+
ORIG, Toast.LENGTH_LONG).show();
if(items.contains(ORIG)){
Log.d(TAG, "Element already exists exiting ");
} else {
Log.d(TAG, "Adding Element");
items.add(ORIG);

}


Thread initBkgdThread = new Thread(new Runnable() {
public void run() {
//print_result();
}
});
initBkgdThread.start();

}

public void print_result(String orig){
Log.d(TAG, "HELLO WORLD:" + orig);


}

}

--end of service---

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Problem with losing contains of ArrayList please help

2011-11-20 Thread Graham Bright
Hi Shashi,

Thanks for responding, from myphone i am calling querycontacts which
presents to the user a button called block and textbox. Using querycontacts
i am calling another class (now part of querycontacts) to populate an
arraylist called items. I want to use this arraylist later as a
blockinglist. However from querycontacts when I press the back button the
state info is lost i.e. Arraylist is empty. So I cannot use it. I am
guessing I need a service not an activity. Code would help me here. Thanks
Graham

On 20 Nov 2011 05:25, "shashi asanka"  wrote:

What Do you need? mez with your code . tell what exact you want

do you want to pass  values from one activity to another activity ?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Problem with loosing contains of ArrayList please help

2011-11-19 Thread Graham Bright
Hi all,

I am new to Android programming and I am trying to write an
application which uses a blocking list based on ArrayList.

The class Querycontacts presents to the user contains to block.
Querycontacts calls ExtractContracts to add the number to an ArrayList
checking to see if the number is already on the list.

My problem :-

When I call QueryContacts from myPhone.java then any numbers added to
ArrayList items in ExtractContacts are lost. This is preventing my
from using the ArrayList items.

I am new to Android, so thank you for any help you can provide me.

Kind Regards,
Graham

myPhone.java >>>
case 4:
 Intent z = new Intent(myPhone.this, QueryContacts.class);
startActivity(z);
<<<
Code

myPhone.java

package telephone.org;


import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Button;
import android.widget.Toast;
import android.view.Menu;
import android.view.MenuItem;
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;



public class myPhone extends Activity {
String srvcName = Context.TELEPHONY_SERVICE;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
   final EditText phoneNumber =
(EditText)findViewById(R.id.phone);
   Button phoneDialer = (Button)findViewById(R.id.dialer);

//format number rules
if (!
PhoneNumberUtils.isWellFormedSmsAddress(phoneNumber.toString())){
Toast.makeText(myPhone.this, "Invalid
Number",Toast.LENGTH_SHORT);
 }

phoneDialer.setOnClickListener(new OnClickListener(){
@Override

public void onClick(View v1) {
//NEW CODE VALIDATION FOR CONTACT DETAILS
//REPLACE WITH CONTACTS CLASS
String phoneNumberContact = 
phoneNumber.getText().toString();
if 
(PhoneNumberUtils.isWellFormedSmsAddress(phoneNumberContact)) {
// TODO Auto-generated method stub
Toast toast = Toast.makeText(myPhone.this, 
"Number is " +
phoneNumber.getText().toString(),Toast.LENGTH_SHORT);
toast.show();
Intent intent = new Intent(Intent.ACTION_DIAL);

intent.setData(Uri.parse("tel:"+phoneNumber.getText()));
startActivity(intent);
}
else {
Toast.makeText (myPhone.this, "Invalid 
Phone Number  - try
again", Toast.LENGTH_LONG).show();
}
}
});

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean supRetVal = super.onCreateOptionsMenu(menu);
menu.add(Menu.NONE, 0, Menu.NONE,
getString(R.string.LOCATION_ENABLE));
menu.add(Menu.NONE, 1, Menu.NONE,
getString(R.string.LOCATION_DISABLE));
menu.add(Menu.NONE, 2, Menu.NONE, getString(R.string.IMSI));
menu.add(Menu.NONE, 3, Menu.NONE, getString(R.string.SMS));
menu.add(Menu.NONE, 4, Menu.NONE, getString(R.string.BLOCK));
return supRetVal;

}

//listen for cell changes
  PhoneStateListener cellLocationListener = new
PhoneStateListener() {
@Override
public void onCellLocationChanged(CellLocation location) {
GsmCellLocation gsmLocation = (GsmCellLocation)location;
Toast.makeText(getApplicationContext(),"CELL ID:" +
String.valueOf(gsmLocation.getCid()) + "  LAC:" +
String.valueOf(gsmLocation.getLac()), Toast.LENGTH_LONG).show();

}
};

@Override
public boolean onOptionsItemSelected(MenuItem item){

switch (item.getItemId()) {
case 0:
Toast.makeText(getApplicationContext(),"Enabling Cell location
tracking", Toast.LENGTH_LONG).show();
TelephonyManager telephonyManager =
(TelephonyManager)getSystemService(srvcName);  //must be declared here
or after context

telephonyManager.listen(cellLocationListener,PhoneStateListener.LISTEN_CELL_LOCATION);
return true;
case 1:
Toast.makeText(getApplicationContext(),"Disabling Cell location
tracking", Toast.LENGTH_LONG).show();
TelephonyManager tm = (TelephonyManager)
getSystemService(srvcNa

[android-developers] ANDROID TOAST ARRAYLIST NULL POINTER

2011-11-13 Thread Graham Bright
Hi I get a null point exception with the following code can anyone
help ?

I want to go through my array items and print each item to the user
using a toast message

Thanks
Graham

package gb.org;


import java.util.Arrays;
import java.util.ArrayList;
import android.widget.Toast;
import android.app.Activity;


//I need an activity for my toast to work correctly
public class ExtractContacts extends Activity{

 ArrayList items=new ArrayList();



public void addToArray(String contactToBlock) {

//add a number to items
contactToBlock.toString();
items.add(contactToBlock);
String Temp;
for (int i =0;ihttp://groups.google.com/group/android-developers?hl=en


[android-developers] Re: onItemLongClockListener - ArrayList throws IndexOutOfBoundsException

2011-10-12 Thread Graham Bright
Found the problem


myList.remove(*this*); //remove the current object , *postion* throws an
exception


On Tue, Oct 11, 2011 at 11:37 AM, Graham Bright wrote:

> Hi,
>
> When I try to remove the list element in my ArrayLilst I get
> IndexOutofBoundsException. Specifically in OnItemLongClickListener.
>
> Can anyone help ?
>
> Thanks,
>
> Graham
>
> package listmodified.org;
>
> import java.util.Arrays;
> import java.util.ArrayList;
> import android.app.ListActivity;
> import android.os.Bundle;
> import android.os.Handler;
> import android.os.Message;
> import android.view.View;
> import android.widget.AdapterView;
> import android.widget.ArrayAdapter;
> import android.widget.ListView;
> import android.widget.TextView;
> import android.widget.AdapterView.OnItemLongClickListener;
> import android.view.GestureDetector.OnGestureListener;
> import android.view.GestureDetector;
> import android.view.MotionEvent;
> import android.widget.Toast;
>
>
>
>
> public class listmodified extends ListActivity implements
> OnGestureListener {
>public ArrayList myList = new
> ArrayList(Arrays.asList(items));
>private TextView selection;  //  MAIN.xml
>public ArrayAdapter adapter; // my adapter
>public OnItemLongClickListener itemDelListener;
>private GestureDetector gestureScanner;
>public int longClickedItem = 0;  //check if longClick is selected or
> not
>private String itemSelected; // for delete function
>private static final byte UPDATE_LIST = 100;
>public AdapterView parent; //used by OnLitemLongClickListener
>public int position;
>
>//tie items to an array list called myList
>public static  String[] items={"lorem", "ipsum", "dolor",
>"sit", "amet",
>"consectetuer", "adipiscing", "elit", "morbi", "vel",
>"ligula", "vitae", "arcu", "aliquet", "mollis",
>"etiam", "vel", "erat", "placerat", "ante",
>"porttitor", "sodales", "pellentesque", "augue", "purus"};
>@Override
>public void onCreate(Bundle icicle) {
>super.onCreate(icicle);
>
>
>//PART OF AdapterView.OnItemClickListener
>//PASS TO listener and catching the selection changes
>OnItemLongClickListener itemDelListener = new
> OnItemLongClickListener(){
>
>//@Override
>public boolean onItemLongClick(AdapterView parent, View
> arg1,
>int position, long arg3) {
>// TODO Auto-generated method stub
>
>  itemSelected=parent.getItemAtPosition(position).toString();
>adapter.remove(itemSelected);
>Toast.makeText(listmodified.this, "position is:" +
> position,
> Toast.LENGTH_SHORT).show();
>myList.remove(position);
>adapter.notifyDataSetChanged();
>
>return false;
>}};
>
>setContentView(R.layout.main);
>
>
>//DEFINE MY OWN VIEW TIEW TO ARRAYLIST myList WHICH CONTAINS STRINGS
>adapter=new
> ArrayAdapter(this,android.R.layout.simple_list_item_1,myList);
>setListAdapter(adapter);
>
>//A VIEW OF THE LIST NECESSARY FOR DELETION
>
>selection=(TextView)findViewById(R.id.selection);
>
>
>// PART OF LONG CLICK SELECTED CODE
>// CALLS IMPLEMENTED METHODS - detect gestures checking my list
> items
>gestureScanner = new GestureDetector(this);
>getListView().setOnTouchListener(new View.OnTouchListener() {
>  @Override
>public boolean onTouch(View v, MotionEvent event) {
>return gestureScanner.onTouchEvent(event);
>}
>});
>
>//UPDATE VIEW DELETE WHEN ONLONG CLICK IS PRESSED
>getListView().setOnItemLongClickListener(itemDelListener);
>
>}
>
>
> //LIST ITEM PRESS CHECKING
>public void onListItemClick(ListView parent, View v,
>int position, long id){
>selection.setText(myList.get(position));
>//check to see if LONGCLICK IS PRESSED
>if (longClickedItem != -1) {
> Toast.makeText(listmodified.this, "A short click
> detected",
> Toast.LENGTH_SHORT).show();
>
>}
>longClickedItem=0

[android-developers] onItemLongClockListener - ArrayList throws IndexOutOfBoundsException

2011-10-12 Thread Graham Bright
Hi,

When I try to remove the list element in my ArrayLilst I get
IndexOutofBoundsException. Specifically in OnItemLongClickListener.

Can anyone help ?

Thanks,

Graham

package listmodified.org;

import java.util.Arrays;
import java.util.ArrayList;
import android.app.ListActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.Toast;




public class listmodified extends ListActivity implements
OnGestureListener {
public ArrayList myList = new
ArrayList(Arrays.asList(items));
private TextView selection;  //  MAIN.xml
public ArrayAdapter adapter; // my adapter
public OnItemLongClickListener itemDelListener;
private GestureDetector gestureScanner;
public int longClickedItem = 0;  //check if longClick is selected or
not
private String itemSelected; // for delete function
private static final byte UPDATE_LIST = 100;
public AdapterView parent; //used by OnLitemLongClickListener
public int position;

//tie items to an array list called myList
public static  String[] items={"lorem", "ipsum", "dolor",
"sit", "amet",
"consectetuer", "adipiscing", "elit", "morbi", "vel",
"ligula", "vitae", "arcu", "aliquet", "mollis",
"etiam", "vel", "erat", "placerat", "ante",
"porttitor", "sodales", "pellentesque", "augue", "purus"};
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);


//PART OF AdapterView.OnItemClickListener
//PASS TO listener and catching the selection changes
OnItemLongClickListener itemDelListener = new
OnItemLongClickListener(){

//@Override
public boolean onItemLongClick(AdapterView parent, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub

itemSelected=parent.getItemAtPosition(position).toString();
adapter.remove(itemSelected);
Toast.makeText(listmodified.this, "position is:" + 
position,
Toast.LENGTH_SHORT).show();
myList.remove(position);
adapter.notifyDataSetChanged();

return false;
}};

setContentView(R.layout.main);


//DEFINE MY OWN VIEW TIEW TO ARRAYLIST myList WHICH CONTAINS STRINGS
adapter=new
ArrayAdapter(this,android.R.layout.simple_list_item_1,myList);
setListAdapter(adapter);

//A VIEW OF THE LIST NECESSARY FOR DELETION

selection=(TextView)findViewById(R.id.selection);


// PART OF LONG CLICK SELECTED CODE
// CALLS IMPLEMENTED METHODS - detect gestures checking my list items
gestureScanner = new GestureDetector(this);
getListView().setOnTouchListener(new View.OnTouchListener() {
  @Override
public boolean onTouch(View v, MotionEvent event) {
return gestureScanner.onTouchEvent(event);
}
});

//UPDATE VIEW DELETE WHEN ONLONG CLICK IS PRESSED
getListView().setOnItemLongClickListener(itemDelListener);

}


//LIST ITEM PRESS CHECKING
public void onListItemClick(ListView parent, View v,
int position, long id){
selection.setText(myList.get(position));
//check to see if LONGCLICK IS PRESSED
if (longClickedItem != -1) {
 Toast.makeText(listmodified.this, "A short click detected",
Toast.LENGTH_SHORT).show();

}
longClickedItem=0;
}

//IMPLEMENTED BY GESTURE
@Override
public boolean onDown(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}


@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX,
float velocityY) {
// TODO Auto-generated method stub
return false;
}


//CHECKS ONLONGPRESS EVENTS SET LONG PRESS TO -1,
//COOL I CAN USE THIS TO SEE IF A LONG CLICK WAS SELECTED LATER ON

@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
Toast.makeText(listmodified.this, "A long click detected",
Toast.LENGTH_SHORT).show();


if (e.getAction()==MotionEvent.ACTION_DOWN)
{

longClickedItem = -1;

}

}


@Override
public bool

[android-developers] SIPMANAGER RETURNS NULL FROM EMULATOR AND SAMSUNG GALAXY S 2

2011-07-29 Thread Graham Bright
Hi,

Has anyone had any luck with SipManager. I have been playing around
with the sipdemo and I have created simple application. The
application creates SIPManager object and attempts to connect using
SipProfile to sip2sip.info.

But manager, api and voip are not supported.

This doesn't work either from the phone or the emulator.

Thanks in advance,

Graham

package gb.org;

import java.text.ParseException;


import android.app.Activity;
import android.net.sip.*;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;

public class gbsip extends Activity {


public SipManager manager = null;
 public SipProfile me = null;


//temporary sip settings
public String name = "gbwien";
public String domain = "sip2sip.info";
public String password = "h7eefbtcff";





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



//this.apiSupport = (EditText) findViewById(R.id.api);
//this.voipSupported = (EditText) findViewById(R.id.voip);

initializeManager();
}

//CREATE A NEW SIP MANAGER INSTANCE
public void initializeManager() {
if(manager == null) {
  manager = SipManager.newInstance(this);
 Toast.makeText(gbsip.this,  "Manager supported " +
manager.isApiSupported(this), Toast.LENGTH_LONG).show();
 Toast.makeText(gbsip.this,  "VOIP supported " +
manager.isVoipSupported(this), Toast.LENGTH_LONG).show();

}
initializeLocalProfile();

}
//LOG INTO SIP ACCOUNT USING A SIP PROFILE LOCAL TO THE
//DEVICE

public void initializeLocalProfile() {
if (manager == null) {
Toast.makeText(gbsip.this, "manager is null  ",
Toast.LENGTH_LONG).show();
return;

}

if (me != null) {
closeLocalProfile();
}


try {

SipProfile.Builder builder = new 
SipProfile.Builder(name, domain);
builder.setPassword(password);
me = builder.build();
Toast.makeText(gbsip.this, "SIP Registration 
successful  ",
Toast.LENGTH_LONG).show();

// Otherwise the methods aren't guaranteed to 
fire.

manager.setRegistrationListener(me.getUriString(), new
SipRegistrationListener() {
public void onRegistering(String localProfileUri)
{
Toast.makeText(gbsip.this, "Registrating with
SIP Server ", Toast.LENGTH_LONG).show();
}

public void onRegistrationDone(String
localProfileUri, long expiryTime) {
Toast.makeText(gbsip.this, "Ready ",
Toast.LENGTH_LONG).show();
}
public void onRegistrationFailed(String
localProfileUri, int errorCode,
String errorMessage) {
Toast.makeText(gbsip.this, "SIP Registration
error  ", Toast.LENGTH_LONG).show();
}
});

} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(gbsip.this, "SIP Registration 
error  ",
Toast.LENGTH_LONG).show();
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(gbsip.this, "SIP Exception has 
occurred  ",
Toast.LENGTH_LONG).show();
}


}

//END OF initializeLocalProfile
public void closeLocalProfile() {
if (manager == null) {
return;
}
try {
if (me != null) {
manager.close(me.getUriString());
}
} catch (Exception ee) {
Log.d("failed ", "Failed to close local profile.",
ee);
}
}



}

Manifest


http://schemas.android.com/apk/res/android";
  package="gb.org"
  android:versionCode="1"
  android:versionName="1.0">


















-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@go

[android-developers] Help needed with OnItemLongClickListener custom adapter - UnsupportedOperationException

2011-06-14 Thread Graham Bright
Hi,

I am new to Android programming and need help with onItemLongClick.

I have implemented an OnItemLongClickListener but when i long click on an
item in my list an UnsupportedOperationException is raised.

I include two files below

listmodified

and my custom adapter

CustomAdapter

Thanks in advance,






listmodified.class
*

package
*listmodified.org;

*

import
*java.util.Arrays;*

import
*java.util.ArrayList;*

import
*android.app.ListActivity;*

import
*android.os.Bundle;*

import
*android.view.View;*

import
*android.widget.AdapterView;*

import
*android.widget.ArrayAdapter;*

import
*android.widget.ListView;*

import
*android.widget.TextView;*

import
*android.widget.AdapterView.OnItemLongClickListener;

 *

public
**class* listmodified *extends* ListActivity {

*private* TextView selection; // MAIN.xml

ArrayAdapter
adapter; // for accessing my adapter

*private* String itemSelected; // for delete function

*public* *static* String[] *items*={"lorem", "ipsum", "dolor",

"sit", "amet",

"consectetuer", "adipiscing", "elit", "morbi", "vel",

"ligula", "vitae", "arcu", "aliquet", "mollis",

"etiam", "vel", "erat", "placerat", "ante",

"porttitor", "sodales", "pellentesque", "augue", "purus"};

@Override

*public* *void* onCreate(Bundle icicle) {

*super*.onCreate(icicle);

//onLongClick must be activity and imported above

OnItemLongClickListener itemDelListener =
*new* OnItemLongClickListener(){

@Override

*public* *boolean* onItemLongClick(AdapterView parent, View arg1,

*int* position, *long* arg3) {

// *TODO* Auto-generated method stub

itemSelected=parent.getItemAtPosition(position).toString();

adapter.remove(itemSelected);

adapter.notifyDataSetChanged();

*return* *false*;

}};

setContentView(R.layout.
*main*);

adapter=*new* CustomAdapter(listmodified.*this*, R.layout.*row*, *items*);

setListAdapter(
adapter);

 selection=(TextView)findViewById(R.id.*selection*);

getListView().setOnItemLongClickListener(itemDelListener);

}

 *public* *void* onListItemClick(ListView parent, View v,

*int* position, *long* id) {

selection.setText(*items*[position]);

}

}






*

mport
**java.util.ArrayList*;

*

import
**android.app.ListActivity*;*

import
*android.content.Context;*

import
**android.os.Bundle*;*

import
*android.view.LayoutInflater;*

import
*android.view.View;*

import
*android.view.ViewGroup;*

import
*android.widget.ArrayAdapter;*

import
*android.widget.ImageView;*

import
**android.widget.ListView*;*

import
*android.widget.TextView;*

import
**android.widget.Toast*;

*

public
**class* CustomAdapter *extends* ArrayAdapter{

LayoutInflater
inflater;

*public* CustomAdapter(Context context, *int* textViewResourceId, String[]
objects) {

*super*(context, textViewResourceId, objects);

Context *myContext* = context;

// *TODO* Auto-generated constructor stub

}

//override default view create my own unique view

*public* View getView(*int* position, View convertView, ViewGroup parent){

View row=convertView;

*if*(row==*null*){

//not sure about the following line of code, something to do with context

LayoutInflater inflater=LayoutInflater.*from*(getContext());

row=inflater.inflate(R.layout.
*row*, *null*);

}

TextView label=(TextView)row.findViewById(R.id.
*weekofday*);

label.setText(listmodified.
*items*[position]);

ImageView icon=(ImageView)row.findViewById(R.id.
*icon*);

*if*(listmodified.*items*[position].length()<=1){

icon=(ImageView)row.findViewById(R.id.
*icon*);

icon.setImageResource(R.drawable.
*small_x_dark*);

}

*else*{

icon.setImageResource(R.drawable.
*ok*);

}

*return* row; //This function must return something

}

 }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en