Tag Archives: android

silence camera sound when taking picture in samsung galaxy s3 4g

Unfortunately there is no menu allowing to turn off sound when takin gpictures with my samsung s3 4g. Even when all sound volumes are set to no-sound levels, camera is still generating noise! Here is how I did to turn it off forever: It is necessary to gain root access: SRSRoot Once Click Root free software worked fine for me (second rooting method) Once rooting is successful, install adb and connect via console to your phone by running adb shell From within the shell, activate root user by running su At this stage, connection is still read-only, it is now […]

xoom: restore to factory defaults (unroot, restore original rom and re-lock)

I recently bought a second-hand Motorola xoom tablet device and found out that it had been rooted and the rom was not the original one (easy to detect due to very ugly splash-screen). Here is a step-by-step guide on how to restore original system: connect the power cord to the tablet ensure android sdk is correctly installed on your computer download the original rom from motorola website, ensure to retrieve the one matching your device version: http://developer.motorola.com/products/software/ unzip the content of downloaded zip from motorola website. You should end-up with the following 4 files: boot.img recovery.img system.img userdata.img add correct […]

android: how to pass values between activities

When you want to pass values between activities, you do it via ‘intent’ objects. The key is to specify that you expect a value to be returned when you start the child-activity. Instead of calling: this.startActivity(my_intent); You should call: this.startActivityForResult(my_intent, my_query_hook_id); By calling startActivityForResult, you ensure that once child activity is ended, method .onActivityResult(int my_query_hook_id, int my_response_code, Intent my_intent) on your parent activity will be called and you will be able to isolate the appropriate query via your ‘my_query_hook_id’ argument. sources http://developer.android.com/reference/android/app/Activity.html http://stackoverflow.com/questions/5852677/pass-value-between-activity-android

android: create an horizontally scrollable list of pictures [solved]

I tried to create a scollable list of pictures using the following template: <ScrollView android:orientation=”horizontal”> <LinearLayout android:orientation=”horizontal”> <ImageView /> <ImageView /> <ImageView /> <ImageView /> </LinearLayout> </ScrollView> It turned out that my layout was still NOT scrollable. It seems that android:orientation has little effect on the ScrollView element. In fact the solution was to replace <ScrollView> with <HorizontalScrollView> element. Now it is working fine, based on the following schema: <ScrollView android:orientation=”horizontal”> <LinearLayout android:orientation=”horizontal”> <ImageView /> <ImageView /> <ImageView /> <ImageView /> </LinearLayout> </ScrollView> sources http://developer.android.com/reference/android/widget/HorizontalScrollView.html

android: adb does not recognize connected device

I tried to debug my app on a freshly installed environment and found out that my Nexus S device was not recognized properly by android debugger. Below is the output of “adb devices”: List of devices attached ????????????    no permissions This is because I did not create the corresponding udev rule (I am running ubuntu). Simply follow the following instructions: http://developer.android.com/guide/developing/device.html In my case, my vendor is google (vendor id: 18d1). Therefore I performed the following steps: create udev file: sudo vi /etc/udev/rules.d/51-android.rules set file content: SUBSYSTEM==”usb”, ATTR{idVendor}==”18d1″, MODE=”0666″, GROUP=”plugdev” set execute permission to the file: sudo chmod a+r /etc/udev/rules.d/51-android.rules […]

android: how to list all images present in the media gallery

To access data from media gallery, you must use Cursors. Below is a sample code that I use to pick random images from within the picture gallery. Note that it is based on a recently deprecated method ‘managedQuery’ and should be adapted to rely on CursorLoader class instead. Here it is: /** * Return path of a random picture from image library * * Inspired from: http://androidsamples.blogspot.com/2009/06/displaying-list-of-video-files-stored.html * */ public String getRandomPicturePath() { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, null); Random randomGenerator = new Random(); int position = randomGenerator.nextInt(cursor.getCount()); cursor.moveToPosition(position); int column_index = […]

android: use intent to browse and retrieve images

You can easily rely on native applications to browse files and retrieve path of the particular one selected by the user. Using intents, you simply ask for a program to handle your request without having to reinvent the wheel. Here is how to do it. Step 1: call the gallery handler app via intents /** * Open image browser * */ private void _openPictureBrowser() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(“image/*”); intent.putExtra(Intent.EXTRA_TITLE,”A Custom Title”); //optional intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); //optional try { startActivityForResult(intent, _PICK_FILE_RESULT_CODE); } catch (Exception e) { e.printStackTrace(); } } Step 2: define your call back code (ie. code called once […]

android: cannot load external pictures [solved]

I’ve lost several hours trying to find out why I could not load picture based on filePath returned by the gallery app. It happens that this filePath is not the correct one! (ie. the one in the file system!!!). You have to decode it as follows. First let’s see fake-path versus real path: /** * Called when user picked an image via pict-browser */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ switch (requestCode) { case _PICK_FILE_RESULT_CODE: { if (resultCode == RESULT_OK && data != null && data.getData() != null) { String filePath = data.getData().getPath(); //WARNING: this is NOT […]

android: how to localize your app and change current locale

If you want to localize your application to let user choose the language in which to see your app, independently from overall phone language (which is legitimate), here is how to do it: Step1: java code String languageToLoad = “fr”; Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; this.getBaseContext().getResources().updateConfiguration(config, null); Step 2: android manifest Now that you have your java code ready, you need to update your android manifest as well, adding the “android:configChanges=”locale”” to any activity that you want to be able to change the locale. Before: <activity android:name=”.Options”   android:label=”@string/app_name”> </activity> After: […]

android.content.res.Resources$NotFoundException [solved]

When running my app on eclipse & adb instance, I ran into the following error: E/AndroidRuntime(  422): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f040020 E/AndroidRuntime(  422):     at android.content.res.Resources.getText(Resources.java:201) E/AndroidRuntime(  422):     at android.content.Context.getText(Context.java:173) E/AndroidRuntime(  422):     at com.remydamour.taquin.Statistics._fillStatsHistory(Statistics.java:92) Problem is my call to getString(R.string.mystringid) and later-on to getText(R.string.mystringid) was indeed correct! mystringid was valid as such entry existed in my main string.xml file. I could not get rid of this error though, until I found this post: http://www.jiahaoliuliu.com/2011/05/android-runtime-error.html In the end, this is not a real issue, it’s simply a cache issue. I modified my string.xml file, but old […]