android-2.2-froyo

Get index of selected tab in tabHost

旧时模样 提交于 2019-11-30 09:12:00
I'm trying to store the index of the currently selected tab in onSaveInstanceState so I can restore it. However the getCurrentTab apparantely gives me back the String I used in the etTabHost().newTabSpec, which I find a bit weird since the documentation says it returns an int and setCurrentTab also taking an int. Does anyone know how I can get the index of my currently selected tab so I can restore it? Jorgesys you are on the right way, use setOnTabChangedListener to get your selected tab. public class MainActivity extends TabActivity { static TabHost mytabs; mytabs = getTabHost(); mytabs

Call Particular Method after regular interval of time

こ雲淡風輕ζ 提交于 2019-11-30 09:08:54
In my android application I want to call particular method at regular interval of time ie. "after every 5 seconds"...how can i do that....? You can use Timer for the fixed-period execution of a method. Here is a sample of code: final long period = 0; new Timer().schedule(new TimerTask() { @Override public void run() { // do your task here } }, 0, period); herokey This link above is tested and works fine. This is the code to call some method every second. You can change 1000 (= 1 second) to any time you want (e.g. 3 seconds = 3000) public class myActivity extends Activity { private Timer

Could not find INI file in $ANDROID_AVD_HOME nor in $HOME/.android/avd

萝らか妹 提交于 2019-11-30 02:56:32
I cannot start a virtual devices on android SDK when I press the start button on AVD manager, this error shows on my screen: Starting emulator for AVD 'AVD_for_Galaxy_Nexus_by_Google' PANIC: Could not find AVD_for_Galaxy_Nexus_by_Google.ini file in $ANDROID_AVD_HOME nor in $HOME/.android/avd"! Here is the screen shot: You'll just have to set the ANDROID_AVD_HOME environment variable and restart Android Studio. just this command worked for me : sudo cp -R /root/.android $HOME I solved this problem, on Ubuntu, by finding where the .avd and .ini files from the AVD manager were downloaded. By

Vibrate settings on Android 2.2

对着背影说爱祢 提交于 2019-11-30 02:32:25
I'm making a vibrate toggling widget (in fact, its first version is already in the Market) but I'm having some problems with the vibrate settings of Android 2.2. Up to Android 2.1 I have no problem, when I want to disable vibrate I do am.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER,AudioManager.VIBRATE_SETTING_OFF); am.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION,AudioManager.VIBRATE_SETTING_OFF); and the same but with VIBRATE_SETTING_ON on both lines to turn it on, and it works allright. However, since Android 2.2 introduced "Vibrate only in silent mode" and "Vibrate when

Replacing fragments and orientation change

﹥>﹥吖頭↗ 提交于 2019-11-30 01:52:19
I'm developing an Android application targeting 2.x and 3.0 devices and thus I'm using the compatibilty API. I'm testing on Android 2.0. I'm trying to replace a displayed fragment with another one (search form with search results) and I'm experiencing a crash on orientation change when the second (results) fragment is displayed. Basically, I have an activity, that includes a fragment defined in layout xml as <fragment class="org.prevoz.android.search.SearchFormFragment" android:id = "@+id/search_form_fragment" android:layout_width = "fill_parent" android:layout_height = "fill_parent" /> The

Device Check (Samsung vs Others)

拈花ヽ惹草 提交于 2019-11-30 00:57:58
问题 I am working on an application, where there is some code implementation difference for samsung and htc, kindly have a look at my SO question Sending SMS to multiple recepients (Samsung vs HTC) How can I put a check for if the device is samsung or others(htc) 回答1: String manufacturer = android.os.Build.MANUFACTURER; example: Sony Ericsson samsung HTC 回答2: Try this code. String strManufacturer = android.os.Build.MANUFACTURER; It will return name of Manufacturer. Ex Htc String str = android.os

Android; I only have 2 contacts, yet I can obtain 5 from a query, why?

[亡魂溺海] 提交于 2019-11-29 18:21:13
I have setup 2 test contacts in my emulator. I'm running the following query, it should pick them both out, populate my domain object, and add to a list. The output at the bottom should therefore be 2, but it is 5, why is this? (cursor.getCount() is 5 instead of 2) I have stepped through each iteration of the while loop and it is retreving the same contact multiple times, but with different values for POSTCODE , such as the phone number ContentResolver cr = getContentResolver(); Cursor cursor = cr.query(ContactsContract.Data.CONTENT_URI, null, null, null, null); List<MeCercanaContact> contacts

Camera crashes in Android 2.2

我们两清 提交于 2019-11-29 15:44:07
I have tested my application on the Android SDK on everything from 1.5 to 2.2 and the camera code in my activity works fine. Running it on a device with 2.1 is also working. But the same app does not work with 2.2 on HTC Desire and Nexus One and the app crashes. Any ideas why they might be happening? Am using import android.hardware.Camera; . Inside onCreate I have this: preview = (SurfaceView) findViewById(R.id.preview); previewHolder = preview.getHolder(); previewHolder.addCallback(surfaceCallback); previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); And the callback is

Error Android SDK: invalid command-line parameter files [closed]

﹥>﹥吖頭↗ 提交于 2019-11-29 15:23:51
It won't start the virtual device. Why can't things just work?? I'd rather not reinstall everything outside Program Files directory and I don't know and don't care what Eclipse is. deztructicus Its because of the spaces in "Program Files (x86)". From the eclipse menu bar do this Go to Window > Preferences Click Android At the "SDK Location bar" change it from C:\Program Files (x86)\Android\android-sdk to C:\Progra~2\Android\android-sdk It should work perfectly now. (However if you're using a 32bit system then you'd have to change it to 'Progra~1' not 2.) My guess is that you installed the SDK

Cannot get list of public rooms from xmpp Server on Android?

假如想象 提交于 2019-11-29 15:20:54
问题 Hello Everyone i am new to android and i am currently stuck on this. I have to return list of public rooms created on xmpp server. The problem i am having is that the code below works fine for java but there is a null pointer exception in case of android. Any help regarding this would be appreciated. I am using an openfire server and testing it on local machine so that is the reason why i am using ip Address instead of domain name. I am using smack library for JAVA and Asmack Library for