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

Sunday, July 20, 2014

Android - SuppressLint cannot be resolved to a type

After upgrading my Android SDK 20 and ADT-23.0.2, some projects got error "SuppressLint cannot be resolved to a type"



I fixed this by

1. In project property -> Android, change to another API level and change back.
2. change the order in project property ->Java build path -> Order and Export.
3. also please try refresh and clean the project.

Hope it can help and save some hours.

Thursday, October 17, 2013

Fix Android cannot show Logcat, "Invalid Argument"

Fix problem: Android cannot show Logcat, "Invalid Argument"
  • Unplug and plug your device
  • Switch ON/OFF the developer option – USB debugging
  • Clicking at the device on DDMS-Device tab
  • Use command "adb logcat -c" followed by unplug/plug device.
  • On DDMS-Device tab, click the down triangle, choose “Reset adb”
  • Huawei device: *#*#2846579#*#*  Go ProjectMenu / Background Setting / Log setting
  • Use app to show logcat, such as CatLog (play.google.com/store/apps/details?id=com.nolanlawson.logcat
  • Run “echo 1 > /sys/kernel/logger/log_main/enable” in “adb shell”
Reference :
[1] http://stackoverflow.com/questions/2250112/why-doesnt-logcat-show-anything-in-my-android/2945333#2945333
[2] http://stackoverflow.com/questions/3823934/android-the-ddms-shows-the-message-logcat-read-invalid-argument

Tuesday, January 08, 2013

Galaxy Note 2 screen specifications, size, density, aspect

Samsung Galaxy Note I/II screen specifications
--situee's blog

It's important to know the specification the device classifies itself for Android developers.

Galaxy Note 1 calculated ppi is 285; density is xhdpi.
After the ICS update, the device classification changed to "large" and "not long".

Galaxy Note 2 calculated ppi is 267; density is xhdpi.




Resolution
 Size
Density
Aspect
Galaxy Note 2.3
1280x800
Large
xhdpi
Not Long *
Galaxy Note 4.x
1280x800
Normal
xhdpi
Not long
Galaxy Note II
1280x720
Normal
xhdpi
Long


Sunday, November 20, 2011

Resolution Qualifier of Layout Drawable for Android

It's hard to differentiate 800x480 854x480 resolutions. 
Most mobile phones are of these two resolution and goes to qualifier "-normal-hdpi". Both are "-long"
There is resolution qualifier, thougth it's deprecated and recommended to not be used.
something like "-800x400"  "-854x480" (situee's blog)

Wednesday, November 16, 2011

GalaxyTab, Motorola Xoom Screen Desity and Size

Galaxy Tab (7") is 170dpi, it is close to 160dpi, and should be mdpi . However, it is declared as "hdpi" and "large" by Samsung, because it's look better with a hdpi configuration. The new GalaxyTab 10.1 is the same size and resolution as Motorola Xoom, it should be mdpi and xlarge.(situee's blog)

-->
(situee's blog)

Density Screen Size Resolution
Samsung GalaxyTab 7 hdpi 7" large 1024 x 600
Motorola Xoom mdpi 10.1" xlarge 1280 x 800

Pre-scaling, Auto-Scaling and Screen Density

Designing android layout for multiple screens is really confusing.

Pre-scaling

Pre-scaling resource is an important concept.
If resources are not available in the correct density, the system loads the default resources and scales them up or down as needed to match the current screen's density.

Examples:
for an hdpi device, when there is only mdpi image 100x100, then the image will be pre-scaled to 150x150;
for an mdpi device, when there is only hdpi image 150x150, then the image will be pre-scaled to 100x100;

Sunday, November 06, 2011

ERROR: Unknown command 'crunch'

I upgraded the Android ADT to version 15. Everything seems fine until I tried to run an app.

ERROR: Unknown command 'crunch'

Now, use the new Android SDK Manager to upgrade the Android SDK Tools. Then we can forget about the "crunch" problem.

Tuesday, September 13, 2011

dex2jar Decompile APK file

When I find difficult to do something on Android, I will decompile the APK file and try to learn from the messy java code. But anyway, you may really find something useful that help you out.

Let's see how to decompile. We need some tools to decompile. That is dex2jar. You can find it here. And jd-gui to view the jar as java files.


  1. uncompress the apk. On Windows, use winrar to open the apk and extract.
  2. run command "dex2jar.bat classes.dex", "classes.dex.dex2jar.jar" is generated.
  3. use jd-gui.exe to open jar file and view the java code.

Thursday, August 25, 2011

C2DM Implementation Checklist Step by Step

Android C2DM helps your app server push message to your app. It's a mechanism that the server ask the mobile app to fetch new data from server and update itself. C2DM is still in beta version, or Labs version. To use C2DM with your Android applications, you must first signup to request access.

The official doc has a lot of content.
To make it clear, I make the following checklist:


Tuesday, August 23, 2011

C2DM: Get ClientLogin Authentication Token

To send C2DM messages, you should create a new google account as an app-based sender ID and get the ClientLogin Authentication Token.
The most convenient way is using Curl:

curl https://www.google.com/accounts/ClientLogin -d Email=$1 -d Passwd=$2 -d accountType=GOOGLE -d source=companyName-applicationName-versionID -d service=ac2dm

Saturday, July 30, 2011

Android Push Notification Service and C2DM

Apple has support push notification since iOS 3.0
But what about Android??
Android can do this using a long-polling service or keep connected to server.
There are implementations of Android push notification.

1. Cloud to Device Messaging (C2DM) official service by Google
2. AndriodPN at http://sourceforge.net/projects/androidpn/files/
3. Urban Airship Service
4. IBM's MQTT

Wednesday, March 16, 2011

Sharp SH7218U Android folding mobile phone

Recently a new cellphone attracts my eyes.  Sharp SH7218U, really makes a difference. It's the first large-screen/ Android / folding mobile phone I have ever seen.

You can turn the lid clockwise 180 degrees.
Then it becomes a pure touch screen, cell phone. In this mode, here are four virtual Android phone buttons at the bottom of the screen.

Wednesday, February 16, 2011

Unparsed aapt error, main.out.xml

click Run button in Eclipse when I am working in a resource file such as main.xml.
I got error running the project.
a blank xml file "main.out.xml" showed up in editor with message "The document is empty".
In console, "No embedded stylesheet instruction for file".


Thursday, January 06, 2011

Create Android sample project, Invalid project description

I found that android sample codes are not Eclipse projects. You have to create Eclipse projects from the sample codes by choosing "Create project from existing sample."

DO NOT set the sample code directory as your workspace, otherwise an error dialog will popup saying something like "Invalid project description, NotePad overlaps the location of another project: 'NotePad'"

Let's build the sample codes and run as Android application.