Sunday, April 14, 2013

[android help] how custom listview search i do not pass array list to custom listview class



how to search with custom listview when i call list view i don't pass array with it.


now i want to perform search on NAME, please help how i did it?



public class AndroidJSONParsingActivity extends ListActivity {

// JSON Node names
private static final String TAG_NAME = "name";
private static final String TAG_EMAIL = "email";
private static final String TAG_ID = "id";
private static final String TAG_PHONE_MOBILE = "mobile";
EditText search;
int textlength=0;
ListView lv;
ArrayList text_sort = new ArrayList();
ArrayList image_sort = new ArrayList();
ListViewAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//access the controls
showList();
Button addnew = (Button) findViewById(R.id.btnAddNew);
// selecting single ListView item
lv = getListView();
addnew.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(getApplicationContext(), Insrt.class);
startActivity(intent);
}
});
search = (EditText)findViewById(R.id.etSearch);
search.addTextChangedListener(new TextWatcher() {

public void afterTextChanged(Editable s) {
}

public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}

public void onTextChanged(CharSequence s, int start, int before,
int count) {

adapter.getFilter().filter(s);
adapter.notifyDataSetChanged();
}
});


}



private void showList() {
// TODO Auto-generated method stub
ListAdapter adapter = new ListViewAdapter(this);
setListAdapter(adapter);



// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView parent, View view,
int position, long ids) {
// getting values from selected ListItem
String name = ((TextView) view.findViewById(R.id.name)).getText().toString();
String cost = ((TextView) view.findViewById(R.id.email)).getText().toString();
String description = ((TextView) view.findViewById(R.id.mobile)).getText().toString();
String id = ((TextView) view.findViewById(R.id.id)).getText().toString();

// Starting new intent
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(TAG_NAME, name);
in.putExtra(TAG_EMAIL, cost);
in.putExtra(TAG_PHONE_MOBILE, description);
in.putExtra(TAG_ID, id);
startActivity(in);

}
});
}


} now i want to perform search on NAME, please help how i did it?, please help



public class ListViewAdapter extends ArrayAdapter {
private Filter filter;

public ListViewAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
// TODO Auto-generated constructor stub
}
@Override
public Filter getFilter()
{
if (filter == null)
filter = new PkmnNameFilter();

return filter;
}
// url to make request
private static String url = "https://pederstest.net/api/api/employees/";
// JSON Node names
ArrayList TAG_ID= new ArrayList();
ArrayList TAG_NAME= new ArrayList();
ArrayList TAG_EMAIL= new ArrayList();
ArrayList TAG_PHONE_MOBILE= new ArrayList();
static Context context;
JSONArray employee = null;
String id,name,email,mobile;
ArrayList close =new ArrayList();
private Activity activity;
ViewHolder view;

//constructor
public ListViewAdapter(Activity activity)
{
super(context, 0);
this.activity = activity;

// Creating JSON Parser instance
JSONParser jParser = new JSONParser();

// getting JSON string from URL
JSONObject json = jParser.getJSONFromUrl(url);



try {
// Getting Array of Employee
employee = json.getJSONArray("Employee");

// looping through All Employee
for(int i = 0; i < employee.length(); i++)
{
JSONObject c = employee.getJSONObject(i);

// Storing each json item in variable
id = String.valueOf(c.getInt("Id"));
name = c.getString("Name");
email = c.getString("Email");
mobile = c.getString("Mobile");

//adding all get values into array
if(name!="null"&&mobile!="null"){
TAG_NAME.add(name);
TAG_ID.add(id);
TAG_EMAIL.add(email);
TAG_PHONE_MOBILE.add(mobile);
close.add(R.drawable.close);
}


}
} catch (JSONException e) {
e.printStackTrace();
}



}

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

@Override
public Object getItem(int paramInt) {
// TODO Auto-generated method stub
return TAG_NAME.size();
}

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

public static class ViewHolder {
public ImageView deleteButtonImg;
public TextView name,email,mobile,id;



}

@Override
public View getView(final int paramInt, View paramView, final ViewGroup paramViewGroup) {
// TODO Auto-generated method stub

LayoutInflater inflator = activity.getLayoutInflater();
if (paramView == null) {
view = new ViewHolder();
paramView = inflator.inflate(R.layout.list_item, null);

view.name = (TextView) paramView.findViewById(R.id.name);
view.email = (TextView) paramView.findViewById(R.id.email);
view.mobile = (TextView) paramView.findViewById(R.id.mobile);
view.id = (TextView) paramView.findViewById(R.id.id);
view.deleteButtonImg = (ImageView) paramView.findViewById(R.id.ibclose);
paramView.setTag(view);


} else {
view = (ViewHolder) paramView.getTag();
}

view.name.setText(TAG_NAME.get(paramInt));
view.email.setText(TAG_EMAIL.get(paramInt));
view.mobile.setText(TAG_PHONE_MOBILE.get(paramInt));
view.deleteButtonImg.setImageResource(close.get(paramInt));
view.id.setText(TAG_ID.get(paramInt));
view.name.setFocusableInTouchMode(false);
view.name.setFocusable(false);
view.deleteButtonImg.setFocusableInTouchMode(false);
view.deleteButtonImg.setFocusable(false);
view.deleteButtonImg.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
HttpDelete httpDelete = new HttpDelete("https://pederstest.net/api/api/employees/"+TAG_ID.get(paramInt));

httpDelete.setHeader("content-type", "application/json");
JSONObject data = new JSONObject();

try {
data.put("Id", TAG_ID.get(paramInt));

/*StringEntity entity = new StringEntity(data.toString());
httpPost.setEntity(entity);*/

HttpResponse response = httpClient.execute(httpDelete);
String responseString = EntityUtils.toString(response.getEntity());
//int workoutId = responseJSON.getInt("id");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

TAG_NAME.remove(paramInt);
TAG_EMAIL.remove(paramInt);
TAG_PHONE_MOBILE.remove(paramInt);
TAG_ID.remove(paramInt);
close.remove(paramInt);

notifyDataSetChanged();

}
});

return paramView;
}
private class PkmnNameFilter extends Filter
{

@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
// We implement here the filter logic
if (constraint == null || constraint.length() == 0) {
// No filter implemented we return all the list
results.values = TAG_NAME;
results.count = TAG_NAME.size();
}
else {
// We perform filtering operation
List nPlanetList = new ArrayList(TAG_NAME);

for (Object p : TAG_NAME) {
if (((Scheme) p).getName().toUpperCase().startsWith(constraint.toString().toUpperCase()))
nPlanetList.add(p);
}

results.values = nPlanetList;
results.count = nPlanetList.size();

}
return results;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
final ArrayList localItems = (ArrayList) results.values;
notifyDataSetChanged();
clear();
for (Iterator iterator = localItems.iterator(); iterator
.hasNext();) {
String gi = (String) iterator.next();
add(gi);
}
}
}


}


i search on google but i don't understand how to implement in this ?



.

stackoverflow.comm

[android help] exception: cursor index out of range


Here is the code in activity:



//query
final dbhelper helper = new dbhelper(this);
Cursor c = helper.query();
boolean exist =false;
if(c != null && c.moveToFirst()){
Log.d("atestdbChar1no",String.valueOf(c.getCount()));
int i=0;
while(c.isAfterLast()){
Log.d("atestdb1",String.valueOf(i++));
Log.d("atestdb2",String.valueOf(c.getInt(0)));
Log.d("atestdb3",c.getString(1));
Log.d("atestdb4",c.getString(2));
c.moveToNext();
}

//insert
ContentValues values = new ContentValues();
if(!finWords.equals("null")){
if(finWords.length()>index){
String selectWord = finWords.substring(index, index+1);
values.put("character", finChar);
values.put("word", selectWord);
helper.insert(values);


Here is the code in SQLiteOpenHelper:



public void insert(ContentValues values) {
SQLiteDatabase db = getWritableDatabase();
db.insert(TBL_NAME, null, values);
Log.d("test", "dbinsert");
db.close();
}

public Cursor query() {
SQLiteDatabase db = getWritableDatabase();
Cursor c = db.query(TBL_NAME, null, null, null, null, null, null);
Log.d("test", "dbquery");
return c;
}


I can insert data into database but I cannot query them the logcat say the cursor index out of range and just output some data for example just output with id 1,2,4,7 then force close the App but I already insert 14 data what wrong of my code?



.

stackoverflow.comm

[android help] Using If and else to change to change layout file @ runtime

android - Using If and else to change to change layout file @ runtime - Stack Overflow




















I am currently working on a project that i am trying to add an icon making competition and the winner will receive a special app plugin that only the contest winner will get and i would like my app to check if the package(special app plugin) exists on the users device and if it does i would like the app to display an alternate display on run-time.Would i use "if" and "else" statements to achieve this and if so how would i go about this andThanks in advanced.


Note:I have successfully made the app load a different layout depending on the android version so i have a little bit of an idea but need some help.





























you can change your xml file according to your requirement in onCreate()..


as i did in my code, for the different density i used different xml file.



if (metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM) {
setContentView(R.layout.activity_main);
} else if (metrics.densityDpi == DisplayMetrics.DENSITY_LOW) {
setContentView(R.layout.activity_main_small);
} else {
setContentView(R.layout.activity_main_large);
}



















default







.

stackoverflow.comm

[General] [help] custom recovery for Richtel A1 needed


Hi I have china android spreadtrum device. I have already tried many cust. recovery, but none of them are supported. Some shows white screen in recovery mode and rest nothing. I have rooted my device successfully. But stuck with custom recovery. If anybody can help, please help

My device details are given below
android: 2.3.5 baseband hardware: sp6820a cpu hardware: mt6515 Gsm modem: sc8810 Phone brand: alps Cpu speed: 1ghz Cpu model:ARMv7 processor rev 1(v7l)



.

forum.xda-developers.com

[android help] Getting GPS position with libgdx

android - Getting GPS position with libgdx - Stack Overflow



















i wanted to get the gps position of an user while playing a game (libgdx). I found this tutorial for creating an GPSTracker for android phones. my problem is, that this is written for Android Activities/Tasks, but not for libgdx. without libgdx it works perfectly, but i don't know how to use it with libgdx and there isn't any opportunity for using gps with libgdx, yet.


does somebody know if it's possible to use GPS through libgdx and how? it would be very nice.


























You may be able to create your GPSTracker from the Android project wrapper and pass it to the Game instance.




















default






.

stackoverflow.comm

[android help] Creating ND filter calculator


I'm trying to create an application similar to this for a school project: https://play.google.com/store/apps/details?id=com.reidwolcott.expocalc&hl=en


However whereas the application linked above shows aperture and ISO I only wish to have Current exposure, EV adjustment and Equivalent exposure.


Basically the user will be able to pick their current exposure from this list of shutter speeds: 1/8000, 1/4000, 1/2000, 1/1000, 1/500, 1/250, 1/125, 1/60, 1/30, 1/15, 1/8, ¼, ½, 1 sec, 2 sec, 4 sec, 8 sec, 15 sec, 30 sec, 1 min, 2 min, 4 min, 8 min, 16 min, 32 min, 64 min, 128 min


Then if the user selects +1 EV the equivelent shutter speed displayed is 1 down from the current, e.g 1/125 current would be 1/60 equivelent If the user selected +2 EV the equivelent exposure displayed would be 1/30. And so on and so forth.


I am very confused about how to go about coding this concept, if anybody willing to help me out I'd be hugely grateful!


I know SO isn't meant to be a free coding service but I'm just looking for some advice on where to begin.



.

stackoverflow.comm

[android help] success in logcat but empty screen


I currently have this one problem. and because of this, i cant do any other because i have to refer to this page. I would be grateful if anyone could point out the mistake i made.


I wanted to view the details of a specific product where the button from previous page (list) will pass the ID parameter to the page (details). there is no error in the Java code or PHP code. i'm sure about this because the Logcat shows the results accordingly (as i added the log thing everywhere). but the page is empty in the emulator. i don't understand why this happens as the layout is designed same as other pages as well. In case you need the code, its as below:


Java code: list.java



ListView lv = getListView();

lv.setOnItemClickListener(new OnItemClickListener() {

public void onItemClick(AdapterView parent, View view,
int position, long id) {

String pid = ((TextView) view.findViewById(R.id.pid)).getText()
.toString();

// Starting new intent
Intent in = new Intent(getApplicationContext(),
details.class);
// sending pid to next activity
in.putExtra(TAG_PID, pid);

// starting new activity and expecting some response back
startActivity(in);
}
});


Java code: details.java



public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book_details);


Intent i = getIntent();

// getting product id (pid) from intent
pid = i.getStringExtra(TAG_PID);

Log.d("pid is:",pid);

new GetProductDetails().execute();

}

class GetProductDetails extends AsyncTask {


@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Details.this);
pDialog.setMessage("Loading. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

protected String doInBackground(String... params) {


runOnUiThread(new Runnable() {
public void run() {

int success;
try {
List params = new ArrayList();
params.add(new BasicNameValuePair("pid", pid));

JSONObject json = jParser.makeHttpRequest(url_product_details, "GET", params);


Log.d("Single Product Details", json.toString());


success = json.getInt(TAG_SUCCESS);
if (success == 1) {

JSONArray productObj = json.getJSONArray(TAG_BOOK);
JSONObject product = productObj.getJSONObject(0);
title = product.getString(TAG_TITLE);
description=product.getString(TAG_CATEGORY);


Layout: details.xml



android:layout_width="match_parent"
android:layout_height="match_parent" >

android:layout_marginTop="70dp"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"/>



thank you so much!



.

stackoverflow.comm

[android help] Is the ANR my faut?


This is my first question, this community has been very helpful in the past and I have not needed to ask anything since I have found my answers here.


I have had my application up a few months and suddenly I received an ANR keyDispatchingTimedOut yesterday. I know the person that gave me this error and he is getting it more than once. This is the only time I have heard of it and none of the users have complained about it.


Could it be on his side? If not is there a way to track it down specifically in the code as in the case of crashes? I am not away of any blocks going on or major functionality occurring in the UI thread, but I could be wrong.


Also, I am noticing the last piece on here does not finish. Is there a way to get the full report from google?


Below is the report, thank you for your help.



DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x400281b8 self=0xd088
| sysTid=2685 nice=0 sched=0/0 cgrp=default handle=-1345002272
| schedstat=( 8487835325 8237002987 36700 )
at com.android.server.SystemServer.init1(Native Method)
at com.android.server.SystemServer.main(SystemServer.java:918)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)

"Binder Thread #10" prio=5 tid=63 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40d21b58 self=0x484108
| sysTid=10504 nice=0 sched=0/0 cgrp=default handle=5716720
| schedstat=( 2387278873 2341007294 13804 )
at dalvik.system.NativeStart.run(Native Method)

"sirf_status_report_handler" prio=5 tid=62 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40ae0288 self=0x35a668
| sysTid=3682 nice=0 sched=0/0 cgrp=default handle=5593744
| schedstat=( 3499502 2617084986 419 )
at dalvik.system.NativeStart.run(Native Method)

"sirf_session_handler" prio=5 tid=61 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x409641b0 self=0x5558c8
| sysTid=3681 nice=0 sched=0/0 cgrp=default handle=4283048
| schedstat=( 3579209 2622337405 419 )
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #9" prio=5 tid=60 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40d20188 self=0x74278
| sysTid=3593 nice=0 sched=0/0 cgrp=default handle=5582808
| schedstat=( 8132365265 8141550572 35471 )
at dalvik.system.NativeStart.run(Native Method)

"pool-1-thread-1" prio=5 tid=59 WAIT
| group="main" sCount=1 dsCount=0 obj=0x40b9d5a8 self=0x1fc300
| sysTid=2942 nice=0 sched=0/0 cgrp=default handle=2815152
| schedstat=( 113781306 2659357783 527 )
at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1424)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:337)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:411)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1021)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)

"GpsLocationProvider" prio=5 tid=58 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bad238 self=0x23ea20
| sysTid=2930 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2818856
| schedstat=( 13854705 33249836592 460 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at com.android.server.location.GpsLocationProvider$GpsLocationProviderThread.run(GpsLocationProvider.java:2891)

"RefQueueWorker@org.apache.http.impl.conn.tsccm.ConnPoolByRoute@407e6060" daemon prio=5 tid=57 WAIT
| group="main" sCount=1 dsCount=0 obj=0x408801c8 self=0x2b4e00
| sysTid=2905 nice=0 sched=0/0 cgrp=default handle=2838328
| schedstat=( 3434085 2612784693 420 )
at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.ref.ReferenceQueue)
at java.lang.Object.wait(Object.java:395)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:107)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:80)
at org.apache.http.impl.conn.tsccm.RefQueueWorker.run(RefQueueWorker.java:102)
at java.lang.Thread.run(Thread.java:1019)

"Binder Thread #8" prio=5 tid=56 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40a4cb58 self=0x208df8
| sysTid=2896 nice=0 sched=0/0 cgrp=default handle=2401344
| schedstat=( 8233373923 8092755308 36551 )
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #7" prio=5 tid=55 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40a813c0 self=0x2afdc8
| sysTid=2892 nice=0 sched=0/0 cgrp=default handle=1552968
| schedstat=( 8330878297 8320865091 36580 )
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #6" prio=5 tid=54 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40b9c878 self=0x17b110
| sysTid=2890 nice=0 sched=0/0 cgrp=default handle=2819272
| schedstat=( 8183716461 8278822470 36332 )
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #5" prio=5 tid=53 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bc9110 self=0x2b0390
| sysTid=2878 nice=0 sched=0/0 cgrp=default handle=2122080
| schedstat=( 8598895582 8631769263 36898 )
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #4" prio=5 tid=52 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40a44568 self=0x1fa708
| sysTid=2862 nice=0 sched=0/0 cgrp=default handle=2345864
| schedstat=( 8039605906 8265176191 36399 )
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #3" prio=5 tid=51 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bef5b0 self=0x29ff60
| sysTid=2844 nice=0 sched=0/0 cgrp=default handle=2117472
| schedstat=( 8241719457 8257298548 36314 )
at dalvik.system.NativeStart.run(Native Method)

"ThrottleService" prio=5 tid=50 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bc84b8 self=0x216cf8
| sysTid=2841 nice=0 sched=0/0 cgrp=default handle=1618080
| schedstat=( 490792513 3604059728 1275 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at android.os.HandlerThread.run(HandlerThread.java:60)

"LocationManagerService" prio=5 tid=49 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bdd4d8 self=0x2adb78
| sysTid=2838 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2641792
| schedstat=( 54834678 31681445646 670 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at com.android.server.LocationManagerService.run(LocationManagerService.java:565)
at java.lang.Thread.run(Thread.java:1019)

"watchdog" prio=5 tid=48 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x4052a600 self=0x20e290
| sysTid=2818 nice=0 sched=0/0 cgrp=default handle=2111408
| schedstat=( 184935095 2608728533 969 )
at java.lang.Object.wait(Native Method)
- waiting on (a com.android.server.Watchdog)
at java.lang.Object.wait(Object.java:395)
at com.android.server.Watchdog.run(Watchdog.java:404)

"android.hardware.SensorManager$SensorThread" prio=5 tid=47 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40a7e770 self=0x29e288
| sysTid=2813 nice=-8 sched=0/0 cgrp=default handle=2156768
| schedstat=( 36371634 2580508142 509 )
at android.hardware.SensorManager.sensors_data_poll(Native Method)
at android.hardware.SensorManager$SensorThread$SensorThreadRunnable.run(SensorManager.java:454)
at java.lang.Thread.run(Thread.java:1019)

"motion_recognition" prio=5 tid=46 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40a1e9c0 self=0x1867f0
| sysTid=2812 nice=0 sched=0/0 cgrp=default handle=1599784
| schedstat=( 5290867 2562076398 420 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at android.os.HandlerThread.run(HandlerThread.java:60)

"CTSA Inject Thread" prio=5 tid=45 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x409db8d8 self=0x184c10
| sysTid=2811 nice=-8 sched=0/0 cgrp=default handle=1064304
| schedstat=( 5243461 2564757647 421 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at android.os.HandlerThread.run(HandlerThread.java:60)

"Thread-54" prio=5 tid=44 WAIT
| group="main" sCount=1 dsCount=0 obj=0x409bed58 self=0x184ad8
| sysTid=2810 nice=0 sched=0/0 cgrp=default handle=2756864
| schedstat=( 3502296 2558605223 420 )
at java.lang.Object.wait(Native Method)
- waiting on (a java.util.LinkedList)
at java.lang.Object.wait(Object.java:358)
at com.android.internal.atfwd.AtCkpdCmdHandler$1.run(AtCkpdCmdHandler.java:226)

"backup" prio=5 tid=43 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40baa010 self=0x169230
| sysTid=2796 nice=10 sched=0/0 cgrp=bg_non_interactive handle=1479528
| schedstat=( 41946012 32771440162 616 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at android.os.HandlerThread.run(HandlerThread.java:60)

"SoundPoolThread" prio=5 tid=42 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bac820 self=0x176668
| sysTid=2787 nice=0 sched=0/0 cgrp=default handle=2751816
| schedstat=( 6392413 2542435352 461 )
at dalvik.system.NativeStart.run(Native Method)

"SoundPool" prio=5 tid=41 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bb7b10 self=0x297330
| sysTid=2786 nice=0 sched=0/0 cgrp=default handle=1433808
| schedstat=( 3746788 2550017898 419 )
at dalvik.system.NativeStart.run(Native Method)

"AudioService" prio=5 tid=40 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bbbaa0 self=0x1eba60
| sysTid=2780 nice=0 sched=0/0 cgrp=default handle=1647616
| schedstat=( 31690869 2559762109 506 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at android.media.AudioService$AudioSystemThread.run(AudioService.java:1918)

"SoundPoolThread" prio=5 tid=39 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40bc67f8 self=0x166db8
| sysTid=2779 nice=0 sched=0/0 cgrp=default handle=1514624
| scheds...


.

stackoverflow.comm

[android help] Adding search functionality to my ListView


I have an activity which shows products from MySQL and I want to add some search functionality. But whatever I do I can't make it. I have a lot of code because of parsing data from SQL and I'm developing in Android 2.2.


Please help!


this is my activity



package com.app.app;

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

import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.app.app.R;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class AllProductsActivity extends ListActivity {

// Progress Dialog
private ProgressDialog pDialog;

// Creating JSON Parser object
JSONParser1 jParser1 = new JSONParser1();

ArrayList> productsList;

// url to get all products list
private static String url_all_products = "http://10.0.2.2/android/include/get_all_products.php";

// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_PRODUCTS = "products";
private static final String TAG_PID = "pid";
private static final String TAG_NAME = "name";
private static final String TAG_PRICE = "price";
private static final String TAG_created_at = "created_at";

// products JSONArray
JSONArray products = null;

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

// Hashmap for ListView
productsList = new ArrayList>();

// Loading products in Background Thread
new LoadAllProducts().execute();

// Get listview
ListView lv = getListView();

// on seleting single product
// launching Edit Product Screen
lv.setOnItemClickListener(new OnItemClickListener() {


public void onItemClick(AdapterView parent, View view,
int position, long id) {
// getting values from selected ListItem
String pid = ((TextView) view.findViewById(R.id.pid)).getText()
.toString();

// Starting new intent
Intent in = new Intent(getApplicationContext(),
EditProductActivity.class);
// sending pid to next activity
in.putExtra(TAG_PID, pid);

// starting new activity and expecting some response back
startActivityForResult(in, 100);
}
});

}

// Response from Edit Product Activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// if result code 100
if (resultCode == 100) {
// if result code 100 is received
// means user edited/deleted product
// reload this screen again
Intent intent = getIntent();
finish();
startActivity(intent);
}

}

/**
* Background Async Task to Load all product by making HTTP Request
* */
class LoadAllProducts extends AsyncTask {

/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AllProductsActivity.this);
pDialog.setMessage("Dobavljanje proizvoda. Pricekajte trenutak...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}

/**
* getting All products from url
* */
protected String doInBackground(String... args) {
// Building Parameters
List params = new ArrayList();
// getting JSON string from URL
JSONObject json1 = jParser1.makeHttpRequest(url_all_products, "GET", params);

// Check your log cat for JSON reponse
Log.d("All Products: ", json1.toString());

try {
// Checking for SUCCESS TAG
int success = json1.getInt(TAG_SUCCESS);

if (success == 1) {
// products found
// Getting Array of Products
products = json1.getJSONArray(TAG_PRODUCTS);

// looping through All Products
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);

// Storing each json item in variable
String id = c.getString(TAG_PID);
String name = c.getString(TAG_NAME);
String price = c.getString(TAG_PRICE);
String datum = c.getString(TAG_created_at);

// creating new HashMap
HashMap map = new HashMap();

// adding each child node to HashMap key => value
map.put(TAG_PID, id);
map.put(TAG_NAME, name);
map.put(TAG_PRICE, price);
map.put(TAG_created_at, datum);

// adding HashList to ArrayList
productsList.add(map);
}
} else {
// no products found
// Launch Add New product Activity
Intent i = new Intent(getApplicationContext(),
NewProductActivity.class);
// Closing all previous activities
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
} catch (JSONException e) {
e.printStackTrace();
}

return null;
}

/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
AllProductsActivity.this, productsList,
R.layout.list_item, new String[] { TAG_PID,
TAG_NAME, TAG_PRICE, TAG_created_at},
new int[] { R.id.pid, R.id.name, R.id.price, R.id.datum });
// updating listview
setListAdapter(adapter);
}
});

}

}
}


xml file




android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

android:id="@+id/bigLogo"
android:layout_width="match_parent"
android:layout_height="82dp"
android:layout_x="116dp"
android:layout_y="6dp"
android:background="@raw/iza1"
android:src="@raw/log" />



android:id="@+id/inputSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Pretraži..."
android:inputType="textVisiblePassword" />

android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@raw/iza1" />




.

stackoverflow.comm

[android help] FaceBook chating issue in android


Actually i am new in android and i want to create fb chat apps.... can any one help me about in facebook chating. i am using samck library,but i did'nt know how to use its.. i am finguring in google and stackoverflow but i can't exactly find the answer.


i also refer Android facebook Chat connection exception and How to create XMPP chat client for facebook?


but i am not solving the issues.


anybody plz guide me..



.

stackoverflow.comm

[android help] killing other applications

android - killing other applications - Stack Overflow



















i want to kill the sms application when it is open. for this purpose i write a service . that checks if sms application is opened. and if it is then it kills this. i am using ActivityManager class. here is my code but when i launch sms application it nevers ends. why? is it possible ? if yes then please help.



package com.example.activitymanager;

import java.util.List;

import android.app.ActivityManager;
import android.app.IntentService;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;

public class Servicee extends IntentService {
ActivityManager am;
Handler handler = new Handler();
Runnable r = new Runnable() {

@Override
public void run() {
List list = am
.getRunningTasks(Integer.MAX_VALUE);
for (ActivityManager.RunningTaskInfo task : list) {
if (task.baseActivity.getPackageName()
.equals("com.android.mms")) {
am.restartPackage(task.baseActivity.getPackageName());
}
}
handler.postDelayed(this, 5000);
}
};

public Servicee() {
super("");
}

@Override
protected void onHandleIntent(Intent arg0) {
am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
handler.postDelayed(r, 2000);

}

}















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

[android help] Higher API calls while lower SDK targeting

android - Higher API calls while lower SDK targeting - Stack Overflow



















My app supports minSdkVersion=10 and targeting 16. I want to call methods specific to API level >= 14 if a specific device supports them. I could check running OS version at runtime and whether call or not higher API methods but when I specify min SDK version, methods that exist only in versions higher than 10 are not visible. Is there any way to use higher API methods than minSdkVersion?





























You can test the device's API with this:



if(android.os.Build.VERSION.SDK_INT >= 14) {
// Do something fancy
}
else {
// Do something regular
}






















Methods from higher API are invisible and inaccessible because project's target SDK is lower than SDK which methods are going to be used. For example: if you want to use methods from API 14 Android project target SDK should be at least 14 or even better the latest (currently 16). That is kind of obvious but I missed it. After that the solution Sam gave a reference to is in use.






















In addition of checking the current version you should also add @SuppressLint("NewApi")to your method so the compiler want yell about it.




















default






.

stackoverflow.comm

[android help] How to get a 3D accordion effect on Android


I am planning to port the great 3D accordion effect found on iOS (https://github.com/xyfeng/XYOrigami) on Android.


so far I have something pretty close, here is a screenshot with "pinch-to-fold" to fold the view: http://imageshack.us/photo/my-images/822/3daccordion.png


as you can see, it remains a space between 2 opposite "panels". The process is simple:


  1. take the canvas of the main Layout

  2. create a Custom surface view which will replace all the view of the layout

  3. set as background image the taken canvas

  4. cut this canvas into X panels (here 16)

  5. redraw the surfaceview with all the "panels" with a calculated matrix

  6. recalculate the matrix while pinching to give the "folding effect"

here is the transformation matrix :



private Matrix getFoldingMatrix(int angle, int startFrom,int position) {
int move = (int) (
(mWidth - (Math.cos(angle * Math.PI / 180) * mWidth)) * position
) +1*position; //overlap of 1px the panels and not get space between panels

final Camera camera = new Camera();
final Matrix matrix = new Matrix();
camera.save();

camera.rotateY(angle);
camera.getMatrix(matrix);

if(position%2==1){
move += (int) (
(mWidth - (Math.cos(angle * Math.PI / 180) * mWidth))
) ;
matrix.preTranslate(-mWidth, -mHeight/2);
matrix.postTranslate(startFrom+mWidth-move, mHeight/2);
} else {
matrix.preTranslate(0f, -mHeight/2);
matrix.postTranslate(startFrom-move, mHeight/2);
}
camera.restore();

return matrix;
}


what am I getting wrong ? why is there still these spaces between opposite "panels"?



.

stackoverflow.comm

[android help] How to get a preference value into a static String variable?

java - How to get a preference value into a static String variable? - Stack Overflow




















"Cannot make a static reference to the non-static method getPreferences(int) from the type Activity" is the error in my case. 'TimeCardLogin' must be a static variable."



How to get a preference into a static String variable?



public class MyBaseURLContainer extends Activity {

public static String urlPref = "";

static String BASE_URL =
getPreferences(MODE_PRIVATE).getString("Name of variable",urlPref);

public static final String TimeCardLogin = BASE_URL + "/timecard";
}


















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










lang-java






.

stackoverflow.comm

[android help] Referencing jar file of google play service in map v2 project

android - Referencing jar file of google play service in map v2 project - Stack Overflow



















I'm trying to reference the jar file of google-play-service-lib but each time i reference it from the properties window, it gives me a red cross beside the lib. I tried uninstalling the google play service from the SDK service and re-installing it again.. also it didn't work up.


can u please help me solving this issue :)
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

[android help] XmlPullParserException consuming a php web service with Ksoap2 in android


I'm developing an android application that consumes a php based web service. I know there's so many questions about this, but after three days reading I can say the answers didn't help me.


By one hand I've got the php service that looks like this:


Server Side tree folder:



http://IP/WSexample/wsdl/
- hello_server.php
- hello.wsdl


PHP part (hello_server.php):



if (!extension_loaded("soap")) {
dl("php_soap.dll");
}

ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("hello.wsdl");

function sayHello($yourName = '') {
if (empty($yourName)) $yourName = "Mundo";

return "Hello, ".$yourName;
}

$server->addFunction("sayHello");
$server->handle();


XML part (hello.wsdl):




targetNamespace="http://95.39.33.204/WSexample/wsdl/hello.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://95.39.33.204/WSexample/wsdl/hello.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
















transport="http://schemas.xmlsoap.org/soap/http"/>



encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>


encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>





WSDL File for HelloService

location="http://95.39.33.204/WSexample/wsdl/hello_server.php"/>





If I try with my own php client, the server works fine and return Hello and the name I give to it, even if I try with http://validwsdl.com, it gets the proper data...Android is my problem...


I just have a simple Activity to fetch the data, but it always give me a XmlPullParserException when I use the method call of the HttpTransportSE object. The exception says:



org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG @7:49 in java.io.InputStreamReader@405701b0)


Android Code:



public class MainActivity extends Activity {
public static final String NAMESPACE="urn:examples:helloservice";
public static final String METHOD_NAME ="sayHello";
public static final String URL = "http://95.39.33.204/WSexample/wsdl/hello.wsdl";
public static final String SOAP_ACTION = "sayHello";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.tv);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("firstName", "John");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);

HttpTransportSE ht = new HttpTransportSE(URL);

try {
ht.call(SOAP_ACTION, envelope);

SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
tv.setText("Mensaje: "+response.toString());

} catch (XmlPullParserException i){
Log.e("MI_ERROR", i.getMessage());
}catch(Exception e) {
Log.e("MI_ERROR", e.getMessage());
e.printStackTrace();
}

}
}


I think I have something to do with attributes: URL, NAMESPACE, METHOD_NAME and SOAP_ACTION, I've tried changing them to other options but no success.


When I change URL attribute to:



public static final String URL = "http://95.39.33.204/WSexample/wsdl/hello_server.php";


the exception change to:



org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@40570008)


Please help!!!



.

stackoverflow.comm

[General] S3 mini call logs sorted by contacts and not by dates


Hello,

I want to see call log of a contact. I am using S3 mini. It lists logs by dates and I want to choose a contact and see all logs with this contact only.

Thanks in advance for your help.



.

forum.xda-developers.com

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...