Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK
If you look around, people may suggest
Intent.FLAG_ACTIVITY_CLEAR_TOP
but this didn't do the job.
Intent.FLAG_ACTIVITY_CLEAR_TOP
but this didn't do the job.
private static String SERVICE_URI = "http://192.168.1.2/WcfService1/Service1.svc"; private static final String METHOD_NAME = "GetData"; private static final String NAMESPACE = "http://tempuri.org/"; private static final String URL = "http://192.168.1.2/WCFService1/Service1.svc"; private static final String SOAP_ACTION = "http://tempuri.org/IService1/GetData"; SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("value","3"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION,envelope); SoapPrimitive result = (SoapPrimitive)envelope.getResponse(); String resultData = result.toString();
public interface ImeBackListener { public abstract void onImeBack(SearchEditText ctrl, String text); }
public class SearchEditText extends EditText{ private ImeBackListener mOnImeBack; public SearchEditText(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override public boolean onKeyPreIme(int keycode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) if (mOnImeBack != null) mOnImeBack.onImeBack(this, this.getText().toString()); return super.dispatchKeyEvent(event); } public void setOnImeBackListener(ImeBackListener listener) { mOnImeBack = listener; } }
private Handler mHandler = new Handler(); private class MyTimerTask extends TimerTask { @Override public void run() { mHandler.post(new Runnable() { @Override public void run() { Log.i("MyTimerTask", "Cancelling Search Task"); progressBarLayout.setVisibility(LinearLayout.INVISIBLE); if (!stask.isCancelled()) stask.cancel(true); toast = Toast.makeText(mContext,"Could not find any locations", Toast.LENGTH_LONG); toast.show(); } }); } }
timer = new Timer(); timer.schedule(new MyTimerTask(), SEARCH_TIME_OUT);
final Handler mHandler = new Handler(); TimerTask mTimerTask = new TimerTask() { public void run() { mHandler.post(new Runnable() { //handle cancelling here }); }; mTimer = new Timer(); mTimer.schedule(mTimerTask, TIME_OUT);
public class CustomDropDown extends Button { private Context context; private Dialog dialog; private boolean isButtonTextAutoGen; private CheckBox[] checkBox; private TextView[] textView; private int listSize; private ListLayout layout; private final int TEXT_SIZE = 16; public CustomDropDown(Context context, AttributeSet attrs) { super(context, attrs); setBackgroundDrawable(getResources().getDrawable(android.R.drawable.btn_dropdown)); setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL); this.setEllipsize(TextUtils.TruncateAt.END); this.setSingleLine(true); this.context = context; this.isButtonTextAutoGen = true; } // Adapter methods public void setAdapterFromResources(int array_res) { CharSequence[] txt = context.getResources().getTextArray(array_res); setAdapterFromTextArray(txt); } public void setAdapterFromTextArray(CharSequence[] txt) { // Initialize dialog this.dialog = new Dialog(context,R.style.Popup_Dialog) { @Override public void onDetachedFromWindow() { if (isButtonTextAutoGen) setTextOnButtonToSelectedItems(); } }; this.dialog.setContentView(R.layout.popup_list_dialog); this.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.show(); } }); createList(txt); } private void createList(CharSequence[] text) { this.listSize = text.length; textView = new TextView[listSize]; checkBox = new CheckBox[listSize]; layout = (ListLayout) dialog.findViewById(R.id.listlayout); for (int i=0;i<listSize;i++) { View row = LayoutInflater.from(getContext()).inflate(R.layout.single_line_checkbox_item, null); textView[i] = (TextView) row.findViewById(R.id.text); checkBox[i] = (CheckBox) row.findViewById(R.id.checkbox); textView[i].setText(text[i].toString()); textView[i].setTextSize(TypedValue.COMPLEX_UNIT_PX,TEXT_SIZE); layout.addView(row); if (i < (listSize-1)) { LinearLayout divider = new LinearLayout(getContext()); divider.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 1)); divider.setBackgroundColor(Color.argb(160, 160, 160, 160)); layout.addView(divider); } } layout.setChoiceMode(ListLayout.CHOICE_MODE_MULTIPLE); } // Getters/setters public Dialog getDialog() { return this.dialog; } public void setBoolStringToCheckBoxes(String s) { if (s!=null) { for (int i=0;i<s.length();i++) { if (s.charAt(i)=='1') checkBox[i].setChecked(true); else checkBox[i].setChecked(false); } } } public String getCheckBoxValuesToString() { StringBuilder sb = new StringBuilder(); for (int i=0;i<listSize;i++) { if (checkBox[i].isChecked()) sb.append("1"); else sb.append("0"); } return sb.toString(); } public boolean isNoneChecked() { for (int i=0;i<listSize;i++) if (checkBox[i].isChecked()) return false; return true; } public boolean isCheckedAt(int index) { return checkBox[index].isChecked(); } public int getSize() { return listSize; } public void setTextAt(int index, String text) { textView[index].setText(text); } public String getTextAt(int index) { return textView[index].getText().toString(); } public CheckBox[] getCheckBoxArray() { return checkBox; } public void singleChoiceListenerMethod(CheckBox chbx) { for (int i=0;i<listSize;i++) { final int current = i; for (CheckBox b: checkBox) { if (b==chbx) b.setChecked(true); else b.setChecked(false); } } } public void setChoiceMode(int mode) { setChoiceMode(mode,0); } public void setChoiceMode(int mode, int startingPos) { if (mode==ListView.CHOICE_MODE_SINGLE) { ((TextView) dialog.findViewById(R.id.select_option_text)).setText("Select one"); // set up listeners to act like single mode for (int i=0;i<listSize;i++) { final int current = i; checkBox[i].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (CheckBox b: checkBox) { if (b==checkBox[current]) b.setChecked(true); else b.setChecked(false); } } }); } // check if none is check at start, set the first value to true // for (int i=0;i<listSize;i++) { // if (checkBox[i].isChecked()) return; // } // checkBox[startingPos].setChecked(true); } } public int getSelectedItemPosition() { for (int i=0;i<listSize;i++) { if (checkBox[0].isChecked()) return i; } return -1; } public void setTextOnButtonToSelectedItems() { StringBuilder sb = new StringBuilder(); for (int i=0;i<listSize;i++) { if (checkBox[i].isChecked()) sb.append(getTextAt(i)).append(", "); } if (sb.length()!=0) { this.setText(sb.toString().substring(0, sb.length()-2)); } else { this.setText("--Select--"); } } public void setIsButtonTextAutoGen(boolean b) { this.isButtonTextAutoGen = b; } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@color/gray" android:layout_gravity="bottom" android:padding="5dp" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/select_option_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:text="Select one or more" android:textColor="@color/black" /> <Button android:id="@+id/btn_done" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" Done " android:layout_alignParentRight="true" /> </RelativeLayout> <com.att.planitgreen.component.ListLayout android:id="@+id/listlayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#666666" android:padding="5dp" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/checkbox" android:text="text" /> <CheckBox android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" /> </RelativeLayout>
<style name="Popup_Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowAnimationStyle">@style/Animations.PopupDialog</item> </style> <style name="Animations" parent="@android:Animation"/> <style name="Animations.PopupDialog"> <item name="android:windowEnterAnimation">@anim/slide_in_bottom</item> <item name="android:windowExitAnimation">@anim/slide_out_down</item> </style>
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:fromYDelta="100%" android:toYDelta="0" android:duration="@android:integer/config_mediumAnimTime"/> </set>
<?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromYDelta="0" android:toYDelta="100%p" android:duration="@android:integer/config_mediumAnimTime" />