Wednesday, April 24, 2013

[android help] Accessing drawable rescources from a library project in Android

image - Accessing drawable rescources from a library project in Android - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I am trying to search for drawable (pictures) in a resource file in android from my library project Is it possible without the context of the of the actual android project or do I need to add that in? Also how would I be able to find an ID through my library project by using a string as the name of the ID and then convert it to the appropriate integer to set the background resource.


This is what I have tried so far: This works but only looks at the rescources in the library project, I need to look at the resources in the current application project



try
{
Class res = R.drawable.class;
Field field =
res.getField("string_ID_I_want");
drawableId = field.getInt(null);
}

























The actual drawable resources are compiled into your app, so accessing them is no different than accessing normal app resources.


Supposing the ID of the drawable in the library is big_picture. Then R.drawable.big_picture is the ID of the drawable you want to load. You don't have to use introspection. If R.drawable.big_picture is not available, there's something wrong with your project setup (or a compile error).























What's the package name of your library project.


If your package name is com.examplelib.blahblah and your drawable is called myicon, just make sure to


import com.examplelib.blablah.R;


Then in the same file where you imported this R, you can just type R.drawable.myicon

























default






.

stackoverflow.comm

[android help] Android xml layout file is not being added to R.java

Android xml layout file is not being added to R.java - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.



















android:layout_width="fill_parent"
android:layout_height="wrap_content">

android:id="@+id/imageNew"
android:layout_width="50dip"
android:layout_height="50dip"
android:src="@drawable/icon"
android:scaleType="centerCrop"/>







This is my new layout file and it is not being detected by eclipse, nor is it in the R file. I can't create any new layout files or perhaps I'm doing it all wrong. All my older layouts are seen fine.


EDIT:


Also, a layout I had created previously I have edited with a new ID, however that new id is not detected either.


























Clean your project or restart the eclipse, i guess it's the problem with eclipse automatic building.























Look to the imports, the R imported maybe is not correct.






















If ANYTHING is wrong in your layouts, new updates aren't added to the R file. Look at the errors panel, and possibly to a clean rebuild to see what errors are popping up.


Your layout xml is fine. The file itself may have an incompatible name.






















Probably problem in a name xml a file. The name shouldn't contain upper case symbols.






















I have this import


import android.R;


I've deleted this and layout is working again




















default






.

stackoverflow.comm

[android help] ListView selection remained after exit from action mode


The following scenario is not uncommon under activity with list view.


  1. Long pressed an item to enter multi-selection mode.

  2. Select the desired item, then press an action button. For example, delete button.

  3. Exit from multi-selection mode (CHOICE_MODE_MULTIPLE) to none-selection mode (CHOICE_MODE_NONE).

I tested the following situation under Android 4.1.


  1. Scroll the list view to the end till "Item 1023" is seen.

  2. Long press on "Item 1023" to enter action mode.

  3. Select "Item 1019" till "Item 1022". Now, total 5 items is selected including "Item 1023"

  4. Scroll up the list, till only the last visible item is "Item 1019"

  5. Pressed delete button on the top right. 6) Scroll up to the top most.

You will realize along the way, certain rows are being selected. It seems that the recycle views's state_activated stage is not being cleared off, when we exit from multi-selection mode.


Even though I have the following code



@Override
public void onDestroyActionMode(ActionMode mode) {
// http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode
// Using View.post is the key to solve the problem.
final ListView listView = MainActivity.this.getListView();
listView.clearChoices();
for (int i = 0, ei = listView.getChildCount(); i < ei; i++) {
listView.setItemChecked(i, false);
}
listView.post(new Runnable() {
@Override
public void run() {
listView.setChoiceMode(ListView.CHOICE_MODE_NONE);
}
});
actionMode = null;
}


It doesn't help much.


Any workaround on this long standing bug?


I include a complete workable code to demonstrate this bug. https://www.dropbox.com/s/t5zgadtz9q61j00/multimode_bug.zip


p/s This is re-post from https://groups.google.com/forum/?fromgroups=#!topic/android-developers/qeJ-bnGUugg



Using MultiChoiceModeListener couple with CHOICE_MODE_MULTIPLE_MODAL will make this bug gone. However, for device below API level 11 will not able to use this solution.



.

stackoverflow.comm

[android help] How to modify a View from the MainActivity in another class?


I would like update a GridView that I have created in my MainActivity from another class, in my case, called GameplayController.


Specifically, I am trying to simply insert the gridView.setOnItemClickListener(....)... that I currently I have in the MainActivity into a method in the GameplayController class.


I am making a little board game app, and I thought to create a method, "play(), with a loop for the game that runs until the game is over. I started up the GridView in the onCreate of the MainActivity and then I call the method I want the game to run in, but I don't know how to get the GridView I created over to my GameplayController class method "play()" so that I can update it properly directly from there.


Here is the relevant part of my MainActivity:



...
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));

//Create board model, add units to player's list.
UnitArray gameBoardModel = new UnitArray();

//Run the game loop until winner found.
GameplayController.play();

//This ClickListener I don't want here, I want it in my play() method.
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int postion,
long id) {
// Toast for development help only.
Toast.makeText(MainActivity.this, "" + postion,
Toast.LENGTH_SHORT).show();
}
});

}
...


Here is the relevant part of the class I want to control the GridView in:



public class GameplayController {

private static boolean gameOver = false;

/*
* Will run the game loop.
*/
public static void play() {
while (gameOver == false) {
/*
* Update the GridView from Main somehow.
*/


/*
* Will be put in correct place later.
/*
gameOver = true;
}
}
}


This may be totally wrong, but will I need to use a LayoutInflater?



.

stackoverflow.comm

[android help] Integrating an Action Bar with Google Maps API v2


I'm trying to set up an application that allows users to find local businesses and events. I had a working map, but I'm having trouble getting it to integrate into a tabbed action bar. Unfortunately it says "Unfortunately, [app] has stopped." any help would be greatly appreciated.


ActionBarMain.java



@SuppressLint("NewApi")
public class ActionBarMain extends Activity implements TabListener {
RelativeLayout rl;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar_main);
try {
rl = (RelativeLayout) findViewById(R.id.mainLayout);
fragMentTra = getFragmentManager().beginTransaction();
ActionBar bar = getActionBar();
bar.addTab(bar.newTab().setText("Map").setTabListener(this));
bar.addTab(bar.newTab().setText("Businesses").setTabListener(this));
bar.addTab(bar.newTab().setText("Events").setTabListener(this));
bar.addTab(bar.newTab().setText("Facebook").setTabListener(this));

bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_USE_LOGO);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayShowTitleEnabled(false);
bar.show();

} catch (Exception e) {
e.getMessage();
}
/**
* Hiding Action Bar
*/
}

Fragment fram1;
FragmentTransaction fragMentTra = null;
FragMent2 fram2;
FragMent3 fram3;
FragMent4 fram4;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_action_bar_main, menu);
return true;
}

@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {

if (tab.getText().equals("Map")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram1 = new Fragment();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram1);
fragMentTra.commit();
} else if (tab.getText().equals("Businesses")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram2 = new FragMent2();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram2);
fragMentTra.commit();
} else if (tab.getText().equals("Events")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram3 = new FragMent3();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram3);
fragMentTra.commit();
} else if (tab.getText().equals("Facebook")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram2 = new FragMent2();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram2);
fragMentTra.commit();
}

}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {

}

}


FragMent1.java:



public class FragMent1 extends FragmentActivity{

SupportMapFragment mMap;
GoogleMap googleMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar_main);

mMap = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.mainGrid);

googleMap = mMap.getMap();
}
}


AndroidManifest.xml:



package="com.ahmad.actionBar"
android:versionCode="1"
android:versionName="1.0" >

android:name="com.ahmad.actionbar.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>


android:minSdkVersion="11"
android:targetSdkVersion="17" />









android:glEsVersion="0x00020000"
android:required="true"/>

android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:allowBackup="True">
android:name="com.google.android.maps.v2.API_KEY"
android:value="super_secret_key"/>
android:name="com.ahmad.actionbar.MainActivity"
android:label="@string/app_name" >






android:name=".ActionBarMain"
android:label="@string/title_activity_action_bar_main"
android:uiOptions="splitActionBarWhenNarrow" >










EDIT:


fixed a few errors of trying to integrate two apps together and added new logcat.


logcat:



04-24 21:34:33.242: D/AndroidRuntime(11335): Shutting down VM
04-24 21:34:33.242: W/dalvikvm(11335): threadid=1: thread exiting with uncaught exception (group=0x40e26930)
04-24 21:34:33.252: E/AndroidRuntime(11335): FATAL EXCEPTION: main
04-24 21:34:33.252: E/AndroidRuntime(11335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ahmad.actionBar/com.ahmad.actionbar.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ahmad.actionbar.MainActivity" on path: /data/app/com.ahmad.actionBar-2.apk
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.os.Looper.loop(Looper.java:137)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 21:34:33.252: E/AndroidRuntime(11335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-24 21:34:33.252: E/AndroidRuntime(11335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-24 21:34:33.252: E/AndroidRuntime(11335): at dalvik.system.NativeStart.main(Native Method)
04-24 21:34:33.252: E/AndroidRuntime(11335): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ahmad.actionbar.MainActivity" on path: /data/app/com.ahmad.actionBar-2.apk
04-24 21:34:33.252: E/AndroidRuntime(11335): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
04-24 21:34:33.252: E/AndroidRuntime(11335): ... 11 more


.

stackoverflow.comm

[android help] Fragment with Map crashes app when back button is pressed or when orientation changes


I have an Activity that loads 2 tabs in the ActionBar. Tab 1 loads a Fragment that will will inflate a WebView, while Tab 2 loads a Fragment with a map. Initially, I have the problem of changing tabs that causes the app to crash. I have followed the instructions here and implemented onDestroyView().


The problem now is that if I press the back button from Tab 1 (WebView), it exits the Activity properly. But if I do it on Tab 2 (map), the app crashes. The exact same scenario applies to when I change the orientation. I am convinced that it has something to do with the onDestroyView(), but I am not sure what it is.


I have even attempted to Override the back button, but nothing works.


Here is my code to provide some context:


The Activity Class:



public class MyActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Displaying the tabs by calling ActionBar
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

//Details Tab
String label1 = getResources().getString(R.string.details);
Tab tab = actionBar.newTab();
tab.setText(label1);
TabListener t1 = new TabListener(this, label1, DetailsFragment.class);
tab.setTabListener(t1);
actionBar.addTab(tab);

//Map Tab
String label2 = getResources().getString(R.string.map);
tab = actionBar.newTab();
tab.setText(label2);
TabListener t2 = new TabListener(this, label2, MapFragment.class);
tab.setTabListener(t2);
actionBar.addTab(tab);
}

private class TabListener implements ActionBar.TabListener {
private Fragment mFragment;
private final Activity mActivity;
private final String mTag;
private final Class mClass;

/**
* Constructor used each time a new tab is created.
*
* @param activity
* The host Activity, used to instantiate the fragment
* @param tag
* The identifier tag for the fragment
* @param clz
* The fragment's Class, used to instantiate the fragment
*/
public TabListener(Activity activity, String tag, Class clz) {
mActivity = activity;
mTag = tag;
mClass = clz;
}

public void onTabSelected(Tab tab, FragmentTransaction ft) {
// Check if the fragment is already initialized
if (mFragment == null) {
// If not, instantiate and add it to the activity
mFragment = Fragment.instantiate(mActivity, mClass.getName());
ft.add(android.R.id.content, mFragment, mTag);
} else {
// If it exists, simply attach it in order to show it
ft.attach(mFragment);

}
}

public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
// Detach the fragment, because another one is being attached
ft.detach(mFragment);
}
}

public void onTabReselected(Tab tab, FragmentTransaction ft) {
// User selected the already selected tab. Usually do nothing.
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }


DetailsFragment:



public class DetailsFragment extends Fragment {


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View v = inflater.inflate(R.layout.morning, container, false);
WebView webview = (WebView) v.findViewById(R.id.details);
webview.loadUrl("file:///android_asset/pools/details.html");
return v;
} }


MapFragment:



public class MapFragment extends Fragment {

static final LatLng mapLatLng = new LatLng("some numbers", "some numbers");
private GoogleMap map;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View v = inflater.inflate(R.layout.map, container, false);
map = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
Marker amksc = map.addMarker(new MarkerOptions().position(mapLatLng).title("Map"));

map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapLatLng, 18));
return v;
}


@Override
public void onDestroyView() {
super.onDestroyView();
MapFragment destroyMe = (MapFragment)getFragmentManager().findFragmentById(R.id.map);
if (destroyMe != null) {
getFragmentManager().beginTransaction().remove(destroyMe).commit();
}
} }


Thanks for reading such a long post. Any help is greatly appreciated. I will be away for awhile without my laptop (15 days to be exact), so I may not be able to respond and test out your answer, but rest assured that I will =)


Thanks in advance!



.

stackoverflow.comm

[android help] Comparing Double NOT string value in SQLite


I am trying to compare latitude and longitude values in sqlite via Android using a BETWEEN operator. The problem is that the value is always compared as if it's a String and I can't figure out how to compare it as a number. I found this out because using the query "select * from database orderby latitude" returns a list that is not quite ordered since it is not ordered by value. KEY_LAT and KEY_LONG I have stored as both TEXT and REAL, and I get the same output. Please tell me what info you need.


Here is the query:



double high_lat = curr_lat + 100.0;
double high_long = curr_longitude + 100.0;
double low_lat = curr_lat - 100.0;
double low_long = curr_longitude - 100.0;
Cursor cursor = db.query(TABLE_NAME, new String[] {KEY_ID, KEY_NAME, KEY_ADDR, KEY_LAT, KEY_LONG}, select,
new String[]
{KEY_LAT + " BETWEEN " + low_lat + " AND "
+ high_lat + " AND " + KEY_LONG + " BETWEEN " + low_long + " AND "
+ high_long},
null, null, null);


.

stackoverflow.comm

[android help] JSONArray in a ListView with Android


no. runOnUiThread() is necessary because you want to call setListAdapter.


again. - move these two lines



ListAdapter adapter = new SimpleAdapter(Utenti.this, mylist , R.layout.utentii,new String[] { "name" },new int[] { 1});
setListAdapter(adapter);


right after the for(){} loop in the onClick() method.


if you are sure that your mylist list is populated with data in your json call.


basically something like this as a sample:


replace your xml file contents with the following:



android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


then the onCreate():



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

setContentView(R.layout. utentii);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

StrictMode.setThreadPolicy(policy);
lv = getListView();
lv.setTextFilterEnabled(true);

populateListView(); ///populate list first time


//then onClick() event
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View view, int position, long id) {

populateListView();
}
});

}

private void populateListView(){

Thread t = new Thread(new Runnable (){

public void run() {
//Looper.prepare();
JSONObject json =conn("ketut.php");

try {
//Get the element that holds the earthquakes ( JSONArray )
JSONArray ute = json.getJSONArray("success");
final List> mylist =
new ArrayList>();

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

JSONObject e = ute.getJSONObject(i);
System.out.println(e.getString("user"));

mylist.put("name",e.getString("user"));
}

runOnUiThread(new Runnable() {


public void run() {

ListAdapter adapter = new SimpleAdapter(Utenti.this, mylist , R.layout.utentii,new String[] { "name" },new int[] { 1});
Utenti.this.setListAdapter(adapter);
}

});

} catch (JSONException e) {
System.out.println("4");
e.printStackTrace();
}

}
});
t.start();

}


hope this helps abit.



.

stackoverflow.comm

[android help] Android ListView - change background of element based on values


I have a list which lists EXPENSES and INCOMES. I want ListViewer to automatically change background to either green for Incomes or red for Expenses, would this be possible?



.

stackoverflow.comm

[android help] NoSuchFieldError on findViewById()


There's two android projects I want to merge, one is Main and the other is linked as Library. But I have some troubles on this line:



Button modificarC;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_menu_calificaciones);
modificarC = (Button) findViewById(R.id.btn_aseso); //HERE


I tried Project Clean... also I have android-support-v4.jar on my dependencies


And this is my trace:



04-24 19:39:52.568: E/AndroidRuntime(9486): FATAL EXCEPTION: main
04-24 19:39:52.568: E/AndroidRuntime(9486): java.lang.NoSuchFieldError: com.utez.sistemas.sam.R$id.btn_aseso
04-24 19:39:52.568: E/AndroidRuntime(9486): at com.utez.sistemas.sam.calificaciones.CalificacionesActivity.onCreate(CalificacionesActivity.java:67)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.Activity.performCreate(Activity.java:4465)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.access$600(ActivityThread.java:127)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.os.Looper.loop(Looper.java:137)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.main(ActivityThread.java:4507)
04-24 19:39:52.568: E/AndroidRuntime(9486): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 19:39:52.568: E/AndroidRuntime(9486): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 19:39:52.568: E/AndroidRuntime(9486): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
04-24 19:39:52.568: E/AndroidRuntime(9486): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
04-24 19:39:52.568: E/AndroidRuntime(9486): at dalvik.system.NativeStart.main(Native Method)


Also here is the layout:



style="@style/LoginFormContainer"
android:layout_width="253dp"
android:layout_height="260dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="30dp"
android:orientation="vertical" >

android:id="@+id/btn_alta"
android:layout_width="match_parent"
android:layout_height="63dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="@drawable/btn_altacalif"
android:contentDescription="@string/action_sign_in_register"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:textAlignment="center" />

android:id="@+id/btn_aseso"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:layout_weight="0.16"
android:background="@drawable/btn_modcalif"
android:contentDescription="@string/action_sign_in_register"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:textAlignment="center" />




.

stackoverflow.comm

[android help] AsyncTask will always run even if app is destroyed?

android - AsyncTask will always run even if app is destroyed? - Stack Overflow








Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















i have an application and because you cant do network operations on the main thread im using AsyncTask, so the question is once i execute() the AsyncTask right after that i finish() the activity, and maybe the user will finish() the whole app, so what im wondering is:


  1. will AsyncTask always finish doInBackground() and onPostExecute() even if the app is closed as long as execute() was called when the app was running?

























You will be able to test this. And yes It does. If execute was called you can see Asynctask will still execute UNLESS it does something to the forground or UI related. (it may cause launcher to crash).



However, if it was close by the system. It may or may not continue executing the method. I have already tested and answered here.























onPostExecute() is called from the UI thread - so if the UI thread is no longer running, it will not continue to run. However doInBackGround() is ran from a separate worker thread so it will keep on until done (or if the JVM process is killed by the OS, which is also a possibility). Note that AsyncTasks are only recommended for shorter UI-bound background tasks and not long-running background work (a few seconds).


In short, you can not assume that it will keep on and definitely not assume that it will post it's progress or the calling of onPostExecute().




















default







.

stackoverflow.comm

[General] Transition from iOS to Android - Seeking Experts


OK So here is the deal. I've owned iPhone's since the first one. I would consider myself a VERY advanced user on iOS. I am very close to making the leap from iOS to Android, namely because the HTC ONE is just super sexy and exudes all of the things I love about Apple. I've always told myself that I would love to mess around with Android but wouldn't buy a plastic phone that I can flex in my hand. The HTC ONE has finally come along to make this a reality.

iPhones are very restrictive if you don't jailbreak them, however, once Jailbroken there is basically nothing you can do on Android phone that you can't do on an iPhone. In fact, given my limited knowledge on Android devices, the iPhone can do a few things that I don't know if Android can do. Thus this thread. I want to find out if Android can do some of these things and get as much information as I can before I make the dive.

I hope there are people on this forum with great knowledge of both iOS and Android that can help answer some of these questions. If you don't have great knowledge of th iOS Jailbreak community then you probably can't answer some of my questions.

First things first. I understand that you can unlock the bootloader on many Android phones. It sounds like you currently can do this on the HTC ONE and that unless AT&T patches it soon, when I make my purchase I should be able to do this right away. Does this include unlocking the phone? Can unlocking the phone be done via software? This isn't a huge concern but traveling would be much easier if the answer is yes. Once I have unlocked the bootloader, I understand I can load custom ROMs as they are released for the phone. However, right away I should be able to load custom "launchers" correct? Not sure if I'm using the correct terminology there. Obviously I need some information on this.

Also, what will be the best way to transfer my contacts? I understand that this should be simple, just want everyones feedback on this. Can I simply export them via Bluetooth?

Now on to the more difficult questions. First off. I play a lot of online games where you create an account and then your app is tied to that account. A few examples are like the "Storm8" games that are on iOS and Android as well as Dark Summoner which I know is on both. Puzzle & Dragons is another great example. I currently have multiple iteration's of "Puzzle and Dragons" running on my iPhone with multiple user accounts so that I can have multiple characters in that game. Can this be done with Android?

The best thread I found on this is here

However it doesn't look like this is possible. Then someone came along with an idea to rename the .apk and it looks like there may be hope. Hoping some folks can shed some light on this here and if not I might tread over there to see if they can help.

Is there an Android equivalent to iFile? iFile is a great tool on iOS that makes doing the above possible. Browsing throughout the iOS file system to do all kinds of things. I am really hoping there is an equivalent app for Android.

Other apps that I am wondering about equivalent apps to:

MyWi - tethering app made very easy. I don't want to pay AT&T for tethering my phone. I assume android has this but is it through Google Play or do I load another less official app sore to get this?

Also apps like "Fake location" where you can change where you are in case an app doesn't like to function based on where you are located. Sends a different location to an individual app to fake it out.

iBlacklist - as i understand Android does have blacklist apps so you can block certain numbers from bothering you and sending them strait to voicemail.

XBMC - I'm sure android has this, i think it was on Android first.

Game Emulators and ROMs - I'm also sure android has this as the same developers have made them for both. Again, do I get these through Google play or alternative means.

Is there an equivalent to Cydia, where developers can kind of submit there stuff and you can add different sources to get material or is it all through seperate app stores.

I know i have a lot more questions but this is a good start. Please post away.



.

forum.xda-developers.com

[General] Hotspot icon (orange circle)


One thing that bugs me about my HTC Inspire is that if I walk by a hotspot, I will get the orange circle icon at the top of the screen.
The problem is, it won't go away by itself, even if I walk away, or even if I repower the phone.

I don't need to see that icon. I've already disabled wifi notifications but it still appears.

I could live with the orange icon appearing, but it should also go away when I walk away.



.

forum.xda-developers.com

[General] stuck on tmobile contract?


ive looked around a lot for a answer to this question but i havent found anything so im gonna ask you, i recently signed a contract with tmobile in december,and i purchased a galaxy s3, but since i cracked it a little bit and i like the htc one and the new simple choice plan, is it possible i can just "switch" over to the simple choice plan? Would i have to buy out from my current contract and pay like 200 dollars?If i were to switch to the simple choice plan it would be cheaper and i would own a better phone. Please answer



.

forum.xda-developers.com

[General] Outlook for Mac Calendar with Galaxy S3 calendar


First off; Sorry if this has been posted before.

I have a mac with Outlook for MAC 2011 on it. I have had a GS3 for almost a year (made the switch from BB). Since I made the switch I have not been able to get my calendar (or anything for that matter) to sync. Google Sync is no longer an option. I am not too worried about contacts, as they have all been uploaded etc... but can anyone tell me how I can sync my calendar with google calendar, or with my phone calendar?

Thanks in advance



.

forum.xda-developers.com

[General] Creating cool home screens


Most screens are just nice wallpaper and well chosen widgets, none of which requires rooting.

You can make your life easier with a new launcher, which allows you to customizethe layout and orientation of the home screen/screens.

Now go forth and research!

Sent from my Nexus 4 using Android Central Forums



.

forum.xda-developers.com

[General] Dropbox, Android with Windows 8


Any of you Android users out there that use dropbox and on your PC also?

I am trying to use an excel sheet which I had pinned to the taskbar above excel

Well, I had to move the sheet I am speaking of to dropbox folder, and now it no longer stays pinned to excel on the taskbar

Any help with this would be appreciated

(as an addendum, if anyone has a link to iphone 5 alerts, not ringtones, I'd be grateful as well)



.

forum.xda-developers.com

[android help] Android SampleBrowserPlugin Installation failed


I am trying to install the samplebrowserplugin given in the android source code. As given here (https://github.com/android/platform_development/tree/master/samples/BrowserPlugin), I am able to follow it to the second step (make SampleBrowserPlugin). I have the .apk file now but when I try to install it using adb, all I get is



Failure [INSTALL_FAILED_DEXOPT]


When I run logcat, among various messages, I see



DexOptZ: zip archive '/data/app/com.android.sampleplugin-1.apk' does not include classes.dex


.

stackoverflow.comm

[android help] ProgressDialog not showing up despite show() is called


I've got a strange problem, a Dialog being created and called for "show()" but not being visible in my activity...


The thing is it goes through the call "show", I've seen it in the debugger, but nothing...


here is the code:



protected void initializeSpinners() {
spnPlayLists = (Spinner) findViewById(R.id.spnLists);
spnProviders = (Spinner) findViewById(R.id.spnProvider);
spnProviders.setOnItemSelectedListener(new OnItemSelectedListener() {

@Override
public void onItemSelected(AdapterView _spinner, View _parent,
int _pos, long _id) {
if (_spinner == spnProviders) {
String[] playListsId = core.getAllPlayListsFrom(_pos);
int items = playListsId.length;
**showProgressDialog(items);**
String[] playListsNames = new String[items];
String[] playListsThumbs = new String[items];
playLists = new PlayList[items];
for (int i = 0; i < items; i++) {
String id = playListsId[i];
PlayList playList = core.getPlayList(id, true);
playLists[i] = playList;
playListsNames[i] = playList.title;
playListsThumbs[i] = playList.thumb;
handle.sendEmptyMessage(i);
}
loadPlayLists(playListsNames, playListsThumbs);
myPd_bar.dismiss();
}
}

@Override
public void onNothingSelected(AdapterView _arg0) {
}

});

ProvidersArrayAdapter providersAdapter = new ProvidersArrayAdapter(this);
spnProviders.setAdapter(providersAdapter);
}


and the function called up:



private void showProgressDialog(int _items) {
handle = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
myPd_bar.setProgress(msg.what + 1);
}
};

myPd_bar = new ProgressDialog(Intro.this);
myPd_bar.setMessage("Loading....");
myPd_bar.setTitle("Please Wait..");
myPd_bar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
myPd_bar.setProgress(0);
myPd_bar.setMax(_items);
**myPd_bar.show();**
}


what am I doing bad...?



.

stackoverflow.comm

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...