Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Thursday, September 19, 2019

Android Emulator 29.2.0 problem with Ubuntu 19.04

It just crashed with segmentation fault.

Display card tested: Radeon RX 550, Intel UHD Graphics 630

From https://androidstudio.googleblog.com/2019/09/emulator-2920-stable.html, the OS may crashes with incompatible Vulkan drivers. 

Temporary rollback to emulator 29.1.12-5839083 as a workaround.


Friday, April 27, 2018

Android: get resource ID from resource name

That's a nice resource:

https://stackoverflow.com/questions/3476430/how-to-get-a-resource-id-with-a-known-resource-name

Tuesday, June 23, 2015

True Parallel AsyncTask in Android

Multiple AsyncTask execute() actually execute the tasks sequentially. If the previous task takes a long time to run, the next task can only wait till the previous one finish.

To have a true parallel run, use the following instead of AsyncTask.execute():

    AsyncTask.executeOnExecutor(Executor exec, Params... params)

Tuesday, April 7, 2015

Install Teclast X80H (FB6M) as Android USB in Windows


Teclast X80H (FB6M) is a dual OS (Windows 8.1 + Android 4.4.4) tablet, to install

  1. Install the Samsung USB driver 
  2. Restart the computer
  3. Select Device Manager > The X80H device > Update Driver Software.
  4. Select Browse my computer for driver software
  5. Select Let me pick from a list of device drivers on my computer
  6. Select ADB Interface / Android USB Devices from the list
  7. Select SAMSUNG Android ADB Interface

http://forum.xda-developers.com/windows-8-rt/general/teclast-x80h-8-dual-os-chinese-tablet-t2996314/post59151938#post59151938

Can Teclast simply provide an adb driver link for customer download easily? ... sigh

Wednesday, December 10, 2014

Enable logcat in RedMi / HongMi AOSP 4.2.2

For some reason the logcat in AOSP 4.2.2 maybe disabled by default. To re-enable it, follow the steps below:

  1. Extract the file in /system/etc/init.d/03MTKTweakElse
  2. Comment out the line "rm /dev/log/main", this statement will disable the logcat to function
  3. Push back the file to the device
    C:\> adb push 03MTKTweakElse /system/etc/init.d/03MTKTweakElse
You may not have the privilege to write on the directory /system, to handle this, remount the /system partition using:
  1. Enter the shell
       adb shell
  2. Change to root
       su
  3. Remount the /system as Read-Write
       mount -o remount rw /system

Monday, November 10, 2014

Show multiple lines of title in Android ActionBar

To show multiple lines of title in Android ActionBar, one of the most common solution is to assign some of the text in SubTitle. Here we have another approach:

Basically we get the TextView object of the title in ActionBar, set it's max lines attribute to 2:

int titleId = Resources.getSystem().getIdentifier("action_bar_title","id","android");
TextView title = (TextView) findViewById(titleId);
title.setSingleLine(false);
title.setMaxLines(2);
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);

Then we can set a long title to the ActionBar where the text will be displayed as two lines:

getActionBar().setTitle("... your long title here ...");

Tuesday, November 4, 2014

ArcGIS: Query for a simplified feature set

To query a simplified feature set using QueryTask, you can set the "MaxAllowableOffset" property through

          com.esri.core.tasks.ags.query.Query.setMaxAllowableOffset( )

or if you're using ArcGIS Android SDK version 10.2.4 already, then it should be:

          com.esri.core.tasks.ags.query.QueryParameters.setMaxAllowableOffset( )



Thursday, March 20, 2014

Android ListView Animations

Just found a library ListViewAnimations which delivers nice animations for list items in Android.

To start an animation programatically, we may consider something like:
v.clearAnimation();
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_top_to_bottom);
v.startAnimation(animation);

Friday, April 19, 2013

Avoid Android drawable resource to be scaled automatically

You know, you can have drawable images in Android (e.g. /res/drawable), you normally have it rescaled automatically according to your device dpi (e.g. ldpi, mdpi, hdpi, etc).

If you just don't want Android to scale it for, put your graphic files in /res/drawable-nodpi.

Reference: http://blog.pseudoblue.com/2010/11/15/disable-pre-scaling-of-android-image-resources/

Thursday, February 28, 2013

Customize your ACTION_CHOOSER Intent

For an Android Intent chooser, it is possible to either remove an Intent or add an custom Intent, this is how we do it:

List<Intent> targetedShareIntents = new ArrayList<Intent>();

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "http://www.blogspot.com");

List<ResolveInfo> resInfo = this.getPackageManager().queryIntentActivities(intent, 0);

for (ResolveInfo resolveInfo : resInfo) {
   String packageName = resolveInfo.activityInfo.packageName;

   Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
   targetedShareIntent.setType("text/plain");
   targetedShareIntent.putExtra(Intent.EXTRA_TEXT, "http://www.blogspot.com");
   targetedShareIntent.setPackage(packageName);

   if (!packageName.equals("com.facebook.katana")) { // Remove Facebook Intent share
      targetedShareIntents.add(targetedShareIntent);
   }
  }

// Add my own activity in the share Intent chooser
Intent i = new Intent(this, NextActivity.class);
targetedShareIntents.add(i);

Intent chooserIntent = Intent.createChooser(
   targetedShareIntents.remove(0), "Select app to share");

chooserIntent.putExtra(
   Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));

startActivity(chooserIntent);

Very nice reference from the following posts:

Wednesday, November 14, 2012

Side notes on Android Dev

  1. To make your subclassed ViewPager (android.support.v4.view.ViewPager) work, prepare both the constructors in your class:
    • ViewPager(Context context)
    • ViewPager(Context context, AttributeSet attrs)
  2. In ActionBarSherlock, if you can't get the loading icon work, i.e. setSupportProgressBarIndeterminateVisibility( ) just got no effect at all, then you are very likely have a wrong Window class (android.view.Window) imported. You should include the ActionBarSherlock Window class instead.
    • com.actionbarsherlock.view.Window

Friday, September 21, 2012

Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver error

If you ever come up with the error using ChooserActivity with the Android emulator, you probably don't need to be worried.

It's basically because you only have a single choice to start the intent (e.g. send a message, choose a audio file, choose a picture, etc., in the emulator).

There is just no way to show you the option dialog, and the exception raised. Read the explanation in the following:

http://stackoverflow.com/questions/11308260/chooser-activity-leak-android

Tuesday, September 18, 2012

Android 2.2 SDK with strings.xml having multiple %s


When building the SearchableDictionary examples using 2.2 SDK, the strings.xml contains the following which fails the compilation:

<plurals name="search_results"> 
  <item quantity="one">%d result for \"%s\": </item>
  <item quantity="other">%d results for \"%s\": </item>
</plurals>

We need to change them to the following in order make it compiled:


<plurals name="search_results"> 
  <item quantity="one">%1$d result for \"%2$s\": </item>
  <item quantity="other">%1$d results for \"%2$s\": </item>
</plurals>


Reference:

Thursday, August 30, 2012

Upgrading from ArcGIS Android API v1.1 to v2.0

If you got a ArcGIS Android Project using ArcGIS API v1.1 and switch to v2.0, you will have a runtime exception when you do a pan action in the map view.

   FATAL EXCEPTION: main
   java.lang.UnsatisfiedLinkError: nativeSetAnimating
   com.esri.android.map.MapSurface.nativeSetAnimating(Native Method)
   ...

To solve this problem, you need to:
  1. Create a new ArcGIS Android project using v2.0
  2. Copy the files "libs/armeabi/libGLMapCore.so" and "libs/armeabi-v7a/libGLMapCore.so" back to your original v1.0 project directory
Very stupid right? But choose to use this product is stupid enough.


CSP on Apache

To add CSP to root if sort of funny. The following will NOT work for most cases !!     <LocationMatch "^/$">        Header s...