Search Results

Search found 15838 results on 634 pages for 'android layout'.

Page 23/634 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • Première sortie pour Android 3, le successeur d'Android 2.3 intégrera une version 3D des Google Maps

    Premières sortie pour Android 3 Le successeur d'Android 2.3 intégrera une version 3D des Google MapsLors de la conférence Dive Into Mobile qui se déroule actuellement, Andy Rubin, en charge du développement d'Android, a fait lors de sa keynote une démonstration de la future version d'Android (3.0, alias Honeycomb) sur une tablette Motorola.Le fait marquant de cette présentation (l'UI pour l'instant épurée n'ayant été qu'entraperçue) fut la démonstration de la future version de Google Maps qui sortira dans les jours avenir.De cette présentation il ressort qu'au menu de la prochaine mise à jour de Google Maps nous aurons : le chargement beaucoup plus rapide des cartes ; la gestion de l'affichage de...

    Read the article

  • Android - Create a custom multi-line ListView bound to an ArrayList

    - by Bill Osuch
    The Android HelloListView tutorial shows how to bind a ListView to an array of string objects, but you'll probably outgrow that pretty quickly. This post will show you how to bind the ListView to an ArrayList of custom objects, as well as create a multi-line ListView. Let's say you have some sort of search functionality that returns a list of people, along with addresses and phone numbers. We're going to display that data in three formatted lines for each result, and make it clickable. First, create your new Android project, and create two layout files. Main.xml will probably already be created by default, so paste this in: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:layout_width="fill_parent"   android:layout_height="fill_parent">  <TextView   android:layout_height="wrap_content"   android:text="Custom ListView Contents"   android:gravity="center_vertical|center_horizontal"   android:layout_width="fill_parent" />   <ListView    android:id="@+id/ListView01"    android:layout_height="wrap_content"    android:layout_width="fill_parent"/> </LinearLayout> Next, create a layout file called custom_row_view.xml. This layout will be the template for each individual row in the ListView. You can use pretty much any type of layout - Relative, Table, etc., but for this we'll just use Linear: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:layout_width="fill_parent"   android:layout_height="fill_parent">   <TextView android:id="@+id/name"   android:textSize="14sp"   android:textStyle="bold"   android:textColor="#FFFF00"   android:layout_width="wrap_content"   android:layout_height="wrap_content"/>  <TextView android:id="@+id/cityState"   android:layout_width="wrap_content"   android:layout_height="wrap_content"/>  <TextView android:id="@+id/phone"   android:layout_width="wrap_content"   android:layout_height="wrap_content"/> </LinearLayout> Now, add an object called SearchResults. Paste this code in: public class SearchResults {  private String name = "";  private String cityState = "";  private String phone = "";  public void setName(String name) {   this.name = name;  }  public String getName() {   return name;  }  public void setCityState(String cityState) {   this.cityState = cityState;  }  public String getCityState() {   return cityState;  }  public void setPhone(String phone) {   this.phone = phone;  }  public String getPhone() {   return phone;  } } This is the class that we'll be filling with our data, and loading into an ArrayList. Next, you'll need a custom adapter. This one just extends the BaseAdapter, but you could extend the ArrayAdapter if you prefer. public class MyCustomBaseAdapter extends BaseAdapter {  private static ArrayList<SearchResults> searchArrayList;    private LayoutInflater mInflater;  public MyCustomBaseAdapter(Context context, ArrayList<SearchResults> results) {   searchArrayList = results;   mInflater = LayoutInflater.from(context);  }  public int getCount() {   return searchArrayList.size();  }  public Object getItem(int position) {   return searchArrayList.get(position);  }  public long getItemId(int position) {   return position;  }  public View getView(int position, View convertView, ViewGroup parent) {   ViewHolder holder;   if (convertView == null) {    convertView = mInflater.inflate(R.layout.custom_row_view, null);    holder = new ViewHolder();    holder.txtName = (TextView) convertView.findViewById(R.id.name);    holder.txtCityState = (TextView) convertView.findViewById(R.id.cityState);    holder.txtPhone = (TextView) convertView.findViewById(R.id.phone);    convertView.setTag(holder);   } else {    holder = (ViewHolder) convertView.getTag();   }      holder.txtName.setText(searchArrayList.get(position).getName());   holder.txtCityState.setText(searchArrayList.get(position).getCityState());   holder.txtPhone.setText(searchArrayList.get(position).getPhone());   return convertView;  }  static class ViewHolder {   TextView txtName;   TextView txtCityState;   TextView txtPhone;  } } (This is basically the same as the List14.java API demo) Finally, we'll wire it all up in the main class file: public class CustomListView extends Activity {     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);                 ArrayList<SearchResults> searchResults = GetSearchResults();                 final ListView lv1 = (ListView) findViewById(R.id.ListView01);         lv1.setAdapter(new MyCustomBaseAdapter(this, searchResults));                 lv1.setOnItemClickListener(new OnItemClickListener() {          @Override          public void onItemClick(AdapterView<?> a, View v, int position, long id) {           Object o = lv1.getItemAtPosition(position);           SearchResults fullObject = (SearchResults)o;           Toast.makeText(ListViewBlogPost.this, "You have chosen: " + " " + fullObject.getName(), Toast.LENGTH_LONG).show();          }          });     }         private ArrayList<SearchResults> GetSearchResults(){      ArrayList<SearchResults> results = new ArrayList<SearchResults>();            SearchResults sr1 = new SearchResults();      sr1.setName("John Smith");      sr1.setCityState("Dallas, TX");      sr1.setPhone("214-555-1234");      results.add(sr1);            sr1 = new SearchResults();      sr1.setName("Jane Doe");      sr1.setCityState("Atlanta, GA");      sr1.setPhone("469-555-2587");      results.add(sr1);            sr1 = new SearchResults();      sr1.setName("Steve Young");      sr1.setCityState("Miami, FL");      sr1.setPhone("305-555-7895");      results.add(sr1);            sr1 = new SearchResults();      sr1.setName("Fred Jones");      sr1.setCityState("Las Vegas, NV");      sr1.setPhone("612-555-8214");      results.add(sr1);            return results;     } } Notice that we first get an ArrayList of SearchResults objects (normally this would be from an external data source...), pass it to the custom adapter, then set up a click listener. The listener gets the item that was clicked, converts it back to a SearchResults object, and does whatever it needs to do. Fire it up in the emulator, and you should wind up with something like this:

    Read the article

  • Registering as developer on Google Play store

    - by ChosenOne
    I am registering as a Developer to sell paid applications on the Google Play store and have run into a slight issue: After I paid, I clicked on "Setup merchant details" link. I filled out the business address section, but in the "Public contact" section, Google says this: How can your customers get in touch with you? This information will be made available to your customers when they make a purchase. I work from home. I do not want customers knowing my home address, nor do I want it displayed anywhere online or even accessible by anyone. Should I just enter NA in each of the following fields? Surely Google understands that we have a right to keep such things private? How can I get around this while not getting my account suspended or risk not being approved?

    Read the article

  • Android continue à progresser face à l'iPhone, malgré un Android Market qui enchaîne les bourdes

    Mise à jour du 15/06/10 Android continue à progresser face à l'iPhone Malgré un Android Market qui enchaîne les dysfonctionnements Les chiffres sont bons pour Android. D'après la société de mesure d'audience quantcast, l'OS mobile de Google continue de gagner des parts de marché (PDM) aux Etats-Unis, notamment aux dépends de l'iPhone (et du nouvellement nommé iOS). [IMG]http://ftp-developpez.com/gordon-fowler/android%20progression.png[/IMG] Il n'en reste pas ...

    Read the article

  • Android SDK Manager and AVD Manager doesn't have the correct information and fails to update on Ubun

    - by Johan Carlsson
    I'm trying to install Android SDK on Ubuntu but fail when I try to use the SDK Manager and AVD Manager to install Android platforms. I've downloaded: android-sdk_r04-linux_86.tgz The I start the SDK Manager and AVD Manager (UI) according to the README file: ./tools/android And I get the following Installed Packages: - Install SDK Tools, revision 4 Available Packages: - https://dl-ssl.google.com/android/repoisotry/repository.xml - This repository requires a more recent version of the Tools. Please update- - Android SDK Tools, revision 4 - Archive for Linux (comment: funny since rev 4 seems to be what's installed this is what seems to be installed) Now doing an update of the Android SDK Tools, revision 4 or everything results in 99% progress and then the application hangs. Here's the console feedback: johanc@johan-desktop:~/android/android-sdk-linux_86$ tools/android Starting Android SDK and AVD Manager No command line parameters provided, launching UI. See 'android --help' for operations from the command line. Error: null In the app I choose to upgate the following package: Package Description Android SDK Tools, revision 4 Archive Description Archive for Linux Size: 15 MiB SHA1: 99380c9330c1c3728c836206947350cc00fa28c2 Site https://dl-ssl.google.com/android/repository/repository.xml The console output reads (and the app hangs at 99%): Exception in thread "Installing Archives" java.lang.AssertionError at com.android.sdkuilib.internal.tasks.ProgressTask.incProgress(ProgressTask.java:97) at com.android.sdkuilib.internal.repository.UpdaterData$2.run(UpdaterData.java:358) at com.android.sdkuilib.internal.tasks.ProgressTask$1.run(ProgressTask.java:135)

    Read the article

  • Force close message when preferences are called via menu button

    - by Dan T
    I see no problem in the code. Help? preferences.xml <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <ListPreference android:title="Gender" android:summary="Are you male or female?" android:key="genderPref" android:defaultValue="male" android:entries="@array/genderArray" android:entryValues="@array/genderValues" /> <ListPreference android:title="Weight" android:summary="How much do you weigh?" android:key="weightPref" android:defaultValue="180" android:entries="@array/weightArray" android:entryValues="@array/weightValues" /> </PreferenceScreen> arrays.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="genderArray"> <item>Male</item> <item>Female</item> </string-array> <string-array name="genderValues"> <item>male</item> <item>female</item> </string-array> <string-array name="weightArray"> <item>120</item> <item>150</item> <item>180</item> <item>210</item> <item>240</item> <item>270</item> </string-array> <string-array name="weightValues"> <item>120</item> <item>150</item> <item>180</item> <item>210</item> <item>240</item> <item>270</item> </string-array> </resources> Preferences.java: package com.dantoth.drinkingbuddy; import android.os.Bundle; import android.preference.PreferenceActivity; public class Preferences extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); }; } butts.xml (idk why it's butts but I've gotten used to it now. really just sets up the menu button) <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/settings" android:title="Settings" android:icon="@drawable/ic_menu_settings" /> <item android:id="@+id/archive" android:title="Archive" android:icon="@drawable/ic_menu_archive" /> <item android:id="@+id/new_session" android:title="New Session" android:icon="@drawable/ic_menu_new" /> <item android:id="@+id/about" android:title="About" android:icon="@drawable/ic_menu_about" /> </menu> within DrinkingBuddy.java: @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settings: startActivity(new Intent(this, Preferences.class)); return true; case R.id.archive: Toast.makeText(this, "Expect to see your old drinking sessions here.", Toast.LENGTH_LONG).show(); return true; //ETC. } return false; That's it. I can press the menu button on the phone and see the menu items I created, but when I click on the "Settings" (r.id.settings) it FC. Do I have to do anything to the manifest/other thing to get this to work??

    Read the article

  • Android Camera intent creating two files

    - by Kyle Ramstad
    I am making a program that takes a picture and then shows it's thumbnail. When using the emulator all goes well and the discard button deletes the photo. But on a real device the camera intent saves the image at the imageUri variable and a second one that is named like if I had just opened up the camera and took a picture by itself. private static final int CAMERA_PIC_REQUEST = 1337; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera); //start camera values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "New Picture"); values.put(MediaStore.Images.Media.DESCRIPTION,"From your Camera"); imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); image = (ImageView) findViewById(R.id.ImageView01); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, CAMERA_PIC_REQUEST); //save the image buttons Button save = (Button) findViewById(R.id.Button01); Button close = (Button) findViewById(R.id.Button02); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) { try{ thumbnail = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri); image.setImageBitmap(thumbnail); } catch(Exception e){ e.printStackTrace(); } } else{ finish(); } } public void myClickHandler(View view) { switch (view.getId()) { case R.id.Button01: finish(); break; case R.id.Button02: dicard(); } } private void dicard(){ getContentResolver().delete(imageUri, null, null); finish(); }

    Read the article

  • Dismiss android activity displayed as Popup

    - by Sit
    So i have a service, that starts an activity displayed as a Popup thank's to "android:style/Theme.Dialog" This Activity shows a Listview, with a list of application. On each element of the listview, there is a short description of the application, and two buttons. 1 for launching the application 2 for displaying a toast with more informations. Here is the code in my service : it starts the activity Intent intent = new Intent(this, PopUpActivity.class); intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(intent); this activity uses a custom layout, with a listview, adapted with a custom ArrayAdapter In this adaptater, i've put an action on the start button in order to start the current application Button lanceur = (Button) v.findViewById(R.id.Buttonlancer); lanceur.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { p.start(mcontext); } }); with p.start, i start the application. But now, if i press "back" from the application, i go back to the popup... and i can start another application. I don't want it to be possible. That's why i wish i could dismiss/destroy/finish my PopupActivity, but i can't manage to do it with the code i have.

    Read the article

  • Android Remote Service Keeps Restarting

    - by user244190
    Ok so I've built an app that uses a remote service to do some real time GPS tracking. I am using the below code to start and bind to the service. The remote service uses aidl, sets up a notification icon, runs the GPS and locationListener. In onLocationChanged, a handler sends data back to the caller via the callback. Pretty much straight out of the examples and resources online. I want to allow the service to continue running even if the app closes. When the app is restarted, I want the app to again bind to the service (using the existing service if running) and again receive data from the tracker. I currently have the app mode set to singleTask and cannot use singleinstance due to another issue. My problem is that quit often even after the app and service are shut down either from the app itself, or from AdvancedTaskKiller, or a Forceclose, the service will restart and initialize the GPS. touching on the notification will open the app. I again stop the tracking which removes the notification and turns off the GPS Close the app, and again after a few seconds the service restarts. The only way to stop it is to power off the phone. What can I do to stop this from happening. Does it have to do with the mode of operation? START_NOT_STICKY or START_REDELIVER_INTENT? Or do I need to use stopSelf()? My understanding is that if the service is not running when I use bindService() that the service will be created...so do I really need to use start/stopService also? I thought I would need to use it if I want the service to run even after the app is closed. That is why i do not unbind/stop the service in onDestroy(). Is this correct? I've not seen any other info an this, so I,m not sure where to look. Please Help! Thanks Patrick //Remote Service Startup try{ startService(); }catch (Exception e) { Toast.makeText(ctx, e.getMessage().toString(), Toast.LENGTH_SHORT).show(); } } try{ bindService(); }catch (Exception e) { Toast.makeText(ctx, e.getMessage().toString(), Toast.LENGTH_SHORT).show(); } //Remote service shutdown try { unbindService(); }catch(Exception e) { Toast.makeText(ctx, e.getMessage().toString(), Toast.LENGTH_SHORT).show(); } try{ stopService(); }catch(Exception e) { Toast.makeText(ctx, e.getMessage().toString(), Toast.LENGTH_SHORT).show(); } private void startService() { if( myAdapter.trackServiceStarted() ) { if(SETTING_DEBUG_MODE) Toast.makeText(this, "Service already started", Toast.LENGTH_SHORT).show(); started = true; if(!myAdapter.trackDataExists()) insertTrackData(); updateServiceStatus(); } else { startService( new Intent ( "com.codebase.TRACKING_SERVICE" ) ); Log.d( "startService()", "startService()" ); started = true; updateServiceStatus(); } } private void stopService() { stopService( new Intent ( "com.codebase.TRACKING_SERVICE" ) ); Log.d( "stopService()", "stopService()" ); started = false; updateServiceStatus(); } private void bindService() { bindService(new Intent(ITrackingService.class.getName()), mConnection, Context.BIND_AUTO_CREATE); bindService(new Intent(ITrackingSecondary.class.getName()), mTrackingSecondaryConnection, Context.BIND_AUTO_CREATE); started = true; } private void unbindService() { try { mTrackingService.unregisterCallback(mCallback); } catch (RemoteException e) { // There is nothing special we need to do if the service // has crashed. e.getMessage(); } try { unbindService(mTrackingSecondaryConnection); unbindService(mConnection); } catch (Exception e) { // There is nothing special we need to do if the service // has crashed. e.getMessage(); } started = false; } private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { // This is called when the connection with the service has been // established, giving us the service object we can use to // interact with the service. We are communicating with our // service through an IDL interface, so get a client-side // representation of that from the raw service object. mTrackingService = ITrackingService.Stub.asInterface(service); // We want to monitor the service for as long as we are // connected to it. try { mTrackingService.registerCallback(mCallback); } catch (RemoteException e) { // In this case the service has crashed before we could even // do anything with it; we can count on soon being // disconnected (and then reconnected if it can be restarted) // so there is no need to do anything here. } } public void onServiceDisconnected(ComponentName className) { // This is called when the connection with the service has been // unexpectedly disconnected -- that is, its process crashed. mTrackingService = null; } }; private ServiceConnection mTrackingSecondaryConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { // Connecting to a secondary interface is the same as any // other interface. mTrackingSecondaryService = ITrackingSecondary.Stub.asInterface(service); try{ mTrackingSecondaryService.setTimePrecision(SETTING_TIME_PRECISION); mTrackingSecondaryService.setDistancePrecision(SETTING_DISTANCE_PRECISION); } catch (RemoteException e) { // In this case the service has crashed before we could even // do anything with it; we can count on soon being // disconnected (and then reconnected if it can be restarted) // so there is no need to do anything here. } } public void onServiceDisconnected(ComponentName className) { mTrackingSecondaryService = null; } }; //TrackService onDestry() public void onDestroy() { try{ if(lm != null) { lm.removeUpdates(this); } if(mNotificationManager != null) { mNotificationManager.cancel(R.string.local_service_started); } Toast.makeText(this, "Service stopped", Toast.LENGTH_SHORT).show(); }catch (Exception e){ Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); } // Unregister all callbacks. mCallbacks.kill(); // Remove the next pending message to increment the counter, stopping // the increment loop. mHandler.removeMessages(REPORT_MSG); super.onDestroy(); } ServiceConnectionLeaked: I'm seeing a lot of these: 04-21 09:25:23.347: ERROR/ActivityThread(3246): Activity com.codebase.GPSTest has leaked ServiceConnection com.codebase.GPSTest$6@4482d428 that was originally bound here 04-21 09:25:23.347: ERROR/ActivityThread(3246): android.app.ServiceConnectionLeaked: Activity com.codebase.GPSTest has leaked ServiceConnection com.codebase.GPSTest$6@4482d428 that was originally bound here 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread$PackageInfo$ServiceDispatcher.<init>(ActivityThread.java:977) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread$PackageInfo.getServiceDispatcher(ActivityThread.java:872) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ApplicationContext.bindService(ApplicationContext.java:796) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.content.ContextWrapper.bindService(ContextWrapper.java:337) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at com.codebase.GPSTest.bindService(GPSTest.java:2206) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at com.codebase.GPSTest.onStartStopClick(GPSTest.java:1589) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at com.codebase.GPSTest.onResume(GPSTest.java:1210) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.Activity.performResume(Activity.java:3763) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2937) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2965) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2516) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3625) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread.access$2300(ActivityThread.java:119) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1867) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.os.Handler.dispatchMessage(Handler.java:99) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.os.Looper.loop(Looper.java:123) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at android.app.ActivityThread.main(ActivityThread.java:4363) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at java.lang.reflect.Method.invokeNative(Native Method) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at java.lang.reflect.Method.invoke(Method.java:521) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-21 09:25:23.347: ERROR/ActivityThread(3246): at dalvik.system.NativeStart.main(Native Method) And These: Is this ok, or do I need to make sure i deactivate/close 04-21 09:58:55.487: INFO/dalvikvm(3440): Uncaught exception thrown by finalizer (will be discarded): 04-21 09:58:55.487: INFO/dalvikvm(3440): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@447ef258 on gps_data that has not been deactivated or closed 04-21 09:58:55.487: INFO/dalvikvm(3440): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596) 04-21 09:58:55.487: INFO/dalvikvm(3440): at dalvik.system.NativeStart.run(Native Method)

    Read the article

  • Theme change doesn't work on <4.0 as it should

    - by user1717276
    I have some difficulties with setting up a "theme switcher" programmatically. I would like to switch themes from app (between White (Theme.Light.NoTitleBar) and Dark (Theme.Black.NoTitleBar)) and what I do is: I set a SharedPreference: final String PREFS_NAME = "MyPrefsFile"; final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); final SharedPreferences.Editor editor = settings.edit(); and than I have a two buttons to switch themes (second one is almost identical) Button ThemeWhite = (Button) findViewById(R.id.ThemeWhite); ThemeWhite.setOnClickListener(new OnClickListener() { public void onClick(View v) { editor.putBoolean("Theme", false); editor.commit(); System.exit(2); } }); and in begging of each activity I check SharedPreference boolean theme = settings.getBoolean("Theme", false); if(theme){ this.setTheme(R.style.Theme_NoBarBlack); } else{ this.setTheme(R.style.Theme_NoBar); } setContentView(R.layout.aplikacja); I define themes in file styles.xml in folder values: <resources> <style name="Theme.NoBar" parent="@android:style/Theme.Light.NoTitleBar" /> <style name="Theme.NoBarBlack" parent="@android:style/Theme.NoActionBar" /> in values-v11: <resources> <style name="Theme.NoBar" parent="@android:style/Theme.Holo.Light.NoActionBar" /> <style name="Theme.NoBarBlack" parent="@android:style/Theme.Holo.NoActionBar" /> in values-v14: <resources> <style name="Theme.NoBar" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar" /> <style name="Theme.NoBarBlack" parent="@android:style/Theme.DeviceDefault.NoActionBar" /> manifest file: <application android:theme="@style/Theme.NoBar" > Everything is working excellent on android 4.0 but when I use 2.2 it doesn't change theme - just font is getting white as it should be but there is no dark background. I tried checking if it at least works and changed Theme.NoBarBlack in values (for android <3.0) and its value the same as Theme.NoBar and then when I pressed button font wasn't changed -as it should do.

    Read the article

  • How to play ringtone/alarm sound in Android

    - by Federico
    I have been looking everywhere how to play a ringtone/alarm sound in android. I press a button and I want to play a ringtone/alarm sound. I could not find a easy, straightforward sample. Yes, I already looked at Alarm clock source code... but it is not straightforward and I cannot compile it. I cannot make this work: Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(this, alert); final AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) { player.setAudioStreamType(AudioManager.STREAM_ALARM); player.setLooping(true); player.prepare(); player.start(); } I get this error: 04-11 17:15:27.638: ERROR/MediaPlayerService(30): Couldn't open fd for content://settings/system/ringtone So.. please if somebody knows how to play a default ringtone/alarm let me know. I prefer not to upload any file. Just play a default ringtone.

    Read the article

  • How yo play rington/alarm sound in Android

    - by Federico
    I have been looking everywhere how to play a $#@&! rington/alarm sound in android. I press a button and I want to play a rington/alarm sound. I could not find a easy, strsight forward sample... YES! I already looked at Alarm clock source code... but it is not straight forward and I cannot compile it neither. I cannot make this work: Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(this, alert); final AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) { player.setAudioStreamType(AudioManager.STREAM_ALARM); player.setLooping(true); player.prepare(); player.start(); } I get this error 04-11 17:15:27.638: ERROR/MediaPlayerService(30): Couldn't open fd for content://settings/system/ringtone So.. please if somebody knows how to play a default rington/alarm let me know. I prefer not to upload any file. Just play a default rington. Thanks, Federico

    Read the article

  • Getting hardware floating point with android NDK

    - by Goz
    Hi All, I've begun playing with the android NDK. One of the things I've just learnt is about creating an application.mk file to specify the armv7 abi. I'm building the san-angeles example with the following parameters. APP_MODULES := sanangeles APP_PROJECT_PATH := $(call my-dir)/../ APP_OPTIM := release APP_ABI := armeabi-v7a However this seems to run at exactly the same speed as it did before (ie badly). Am I just GL limited and not CPU limited or is something wrong here? I have noticed when I compile that I get the following command line options emitted: -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb The thing that worries me there is the "softfp". There IS mention of the v7 abi, the VFP fpu stuff and I'm guessing the "thumb" refers to the "thumb-2" instructions (Though I don't know what exactly these are). However that "softfp" does concern me. Shouldn't it be "hardfp"? Anyone got any ideas on these questions? I think I'm probably about ready to start implementing some GL ES 2.0 code for my HTC Desire but I'd like to make sure I'm getting the best possible speed out of it :) Cheers in advance!

    Read the article

  • Android 1.5/1.6 issue with style and autogenerated R.java file

    - by Gaks
    I'm having strange issue with R.java file and styles defined in my resources. Here's some code: In res/values/strings.xml: <style parent="android:Theme.Dialog" name="PopupWindowStyle"> <item name="android:windowBackground">@drawable/bg1</item> <item name="android:textColor">@android:color/black</item> </style> In AndroidManifest.xml: <activity android:name=".RegisterScreen" android:icon="@drawable/ico" android:label="@string/applicationName" android:theme="@style/PopupWindowStyle" android:configChanges="locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale"> </activity> In autogenerated gen/.../R.java: public static final class style { public static final int PopupWindowStyle=0x7f090000; } After some changes in the project, eclipse changed autogenerated value for PopupWindowStyle from 0x7f080000 to 0x7f090000. After that, on Android 1.5, RegisterScreen activity is displayed without PopupWindowStyle style - there is an error displayed in logcat: Skipping entry 0x7f090000 in package table 0 because it is not complex! On Android 1.6 however everything works fine - PopupWindowStyle works like it was before it's integer value has changed. I was testing this issue, by reverting the source code to older revisions. I can confirm, that this problem started occurring after src code commit, which changed two files completely unrelated to this part of code - and an autogenerated R.java file. Any idea what could cause that?

    Read the article

  • Android - Temporal & Ancestral Navigation with ViewPager & Fragments

    - by rascuache
    I'm trying to work out the best way to implement the 'ancestral' and 'temporal' navigation (utilising the up button and back buttons), for a music player I'm working on. Currently, the user is presented with a viewpager, and can page between three main fragments (ArtistMain, AlbumMain and SongMain). Upon choosing an item inside that view, a fragment transaction occurs, and the viewpager goes out of view, replaced by a new fragment (AlbumSub, Songsub or player, depending on where the user came from). The user can then navigate deeper, until a song is chosen, and then they are taken to the 'player' screen. I guess the question is: How do I implement all of this conditional navigation? I'm fairly new to android and programming in general, and I just can't seem to come up with an efficient way to achieve this. At the moment, as each fragment is brought into view, the app is checking to see where the user just came from, and then determines where the user should be taken if back or home is called. This means I have a booleans like "fromArtistMain", "fromAlbumSub", and I'm checking for things like "fromSongSub && fromPlayer".. it's all turning into a bit of a mess. I've drawn a diagram (in paint, sorry!!), to depict the navigation I'm trying to achieve. The yellow represents the 'up' button press, the red is the 'back' button press, and blue is just normal navigation. The green arrows are meant to represent the view paging: Any advice is welcome. It might take something really simple that I've just overlooked. Thanks for your time.

    Read the article

  • Android: Error trying to edit button text after thread sleep

    - by Vass
    (programming Android in Eclipse) I am trying to set up a delay in changing the text in a button. I am getting errors only after there is a delay and the text needs to be changed. Here is the simplified code without a while loop: final Button button_target = (Button) findViewById(R.id.button_target); Thread textChange = new Thread(new Runnable() { public void run(){ button_target.setText("fog"); try{ Thread.sleep(3000); }catch(InterruptedException e){} } }); textChange.start(); And now here is the code where a change of text on the button is required after the sleep which now causes and error and exit (forced): final Button button_target = (Button) findViewById(R.id.button_target); Thread textChange = new Thread(new Runnable() { public void run(){ button_target.setText("cat"); try{ Thread.sleep(3000); }catch(InterruptedException e){} button_target.setText("dog"); } }); textChange.start(); what am I doing to cause the error? Is there another method that I should do to be able to invoke a sleep or delay to the thread so that a text change operation can be performed? (the actual code has a while loop but I believe this form puts the error in highlight)

    Read the article

  • Large ListView containing images in Android

    - by Marco W.
    For various Android applications, I need large ListViews, i.e. such views with 100-300 entries. All entries must be loaded in bulk when the application is started, as some sorting and processing is necessary and the application cannot know which items to display first, otherwise. So far, I've been loading the images for all items in bulk as well, which are then saved in an ArrayList<CustomType> together with the rest of the data for each entry. But of course, this is not a good practice, as you're very likely to have an OutOfMemoryException then: The references to all images in the ArrayList prevent the garbage collector from working. So the best solution is, obviously, to load only the text data in bulk whereas the images are then loaded as needed, right? The Google Play application does this, for example: You can see that images are loaded as you scroll to them, i.e. they are probably loaded in the adapter's getView() method. But with Google Play, this is a different problem, anyway, as the images must be loaded from the Internet, which is not the case for me. My problem is not that loading the images takes too long, but storing them requires too much memory. So what should I do with the images? Load in getView(), when they are really needed? Would make scrolling sluggish. So calling an AsyncTask then? Or just a normal Thread? Parametrize it? I could save the images that are already loaded into a HashMap<String,Bitmap>, so that they don't need to be loaded again in getView(). But if this is done, you have the memory problem again: The HashMap stores references to all images, so in the end, you could have the OutOfMemoryException again. I know that there are already lots of questions here that discuss "Lazy loading" of images. But they mainly cover the problem of slow loading, not too much memory consumption.

    Read the article

  • How to show virtual keypad in an android activity

    - by Maxood
    Why am i not able to show the virtual keyboard in my activity. Here is my code: package som.android.keypad; import android.app.Activity; import android.os.Bundle; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; public class ShowKeypad extends Activity { InputMethodManager imm; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); EditText editText = (EditText)findViewById(R.id.EditText); ((InputMethodManager) getSystemService(this.INPUT_METHOD_SERVICE)).showSoftInput(editText, 0); } } <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="som.android.keypad" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".ShowKeypad" android:windowSoftInputMode="stateAlwaysVisible" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="4" /> </manifest>

    Read the article

  • Make part of layout invisible and the other part visible

    - by JonF
    I would like to make a LinearLayout that was created from xml invisible, and another LinearLayout visible to replace it. The replacement layout starts out as invisible. When I make the originally visible layout invisible, it still leaves space for it on the screen. How can I refresh the screen so that space is gone?

    Read the article

  • Android Layout question

    - by Nils
    Hello, I need to create a map with items on it (the map consists of a drawable object, which represents a room) and I thought about using buttons with background images for the items so that they are clickable. I guess the AbsoluteLayout fits here the best, but unfortunately it's deprecated. What layout would you recommend me for this kind of application ? Is there another layout which supports X/Y coordinates ?

    Read the article

  • Display different layout according to Facebook connection status in Android

    - by Rom Freiman
    I'm building an Android application where I want users to connect by their facebook details. According to my design, when the application starts first time, I want to display a layout with LOGIN facebook button. After the user will perform login for the first time, I dont want to display this layout/activity again - when the application would be relanched, I want t display another (home) screen, and not the LOGIN one. How should I implement this functionality? Thanks

    Read the article

  • My code doesn't recognize layout-xlarge-land?

    - by Justice Bauer
    I am trying to create a landscape and portrait mode only for tablets. For portrait mode I added the files under layout-xlarge and for landscape in tablets I added files under layout-xlarge-land, but just to test if its working I tried switching the background color under landscape to green, but it didnt seem to work. Is there anything else I need to alter for code to recognize landscape mode for tablets?

    Read the article

  • Help identify the layout used here?

    - by Matt Huggins
    I'm working on a layout that comprises some of the same features seen in the screenshot below, but I'm running into a bit of confusion. Can someone help me understand a few points for the screenshot below? What is the root layout used here? How do I get the button bar to remain at the bottom, while the center section scrolls when it is long enough? Similar to the Ok/Cancel buttons seen here, how do I make them each 50% width (minus some margin and padding)?

    Read the article

  • How to create a generic Android XML layout for all activities

    - by zabawaba
    I have an application that needs the same items [5 buttons acting as tabs] in every screen. Is it possible to create a "base XML layout" that has these 5 buttons and then have all the other XML files extend from the bas layout in some way so that I don't have to have multiple buttons that will ultimately have the same functionality. Is there a better approach to this problem that can be supported by API 9

    Read the article

  • Android: Adding static header to the top of a ListActivity

    - by GrandPrix
    Currently I have a class that is extending the ListActivity class. I need to be able to add a few static buttons above the list that are always visible. I've attempted to grab the ListView using getListView() from within the class. Then I used addHeaderView(View) to add a small layout to the top of the screen. Header.xml <?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="fill_parent" > <Button android:id="@+id/testButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Income" android:textSize="15dip" android:layout_weight="1" /> </LinearLayout> Before I set the adapter I do: ListView lv = getListView(); lv.addHeaderView(findViewById(R.layout.header)); This results in nothing happening to the ListView except for it being populated from my database. No buttons appear above it. Another approach I tried as adding padding to the top of the ListView. When I did this it successfully moved down, however, if I added any above it, it pushed the ListView over. No matter what I do it seems as though I cannot put a few buttons above the ListView when I used the ListActivity. Thanks in advance. synic, I tried your suggestion previously. I tried it again just for the sake of sanity, and the button did not display. Below is the layout file for the activity and the code I've implemented in the oncreate(). //My listactivity I am trying to add the header to public class AuditActivity extends ListActivity { Budget budget; @Override public void onCreate(Bundle savedInstanceState) { Cursor test; super.onCreate(savedInstanceState); setContentView(R.layout.audit); ListView lv = getListView(); LayoutInflater infalter = getLayoutInflater(); ViewGroup header = (ViewGroup) infalter.inflate(R.layout.header, lv, false); lv.addHeaderView(header); budget = new Budget(this); /* try { test = budget.getTransactions(); showEvents(test); } finally { } */ // switchTabSpecial(); } Layout.xml for activity: <?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="fill_parent"> <ListView android:id="@android:id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /> </LinearLayout>

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >