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

Monday, October 22, 2012

Check weather application sent to background or not

[java]

public static boolean isApplicationSentToBackground(final Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> tasks = am.getRunningTasks(1);
if (!tasks.isEmpty()) {
ComponentName topActivity = tasks.get(0).topActivity;
if (!topActivity.getPackageName().equals(context.getPackageName())) {
return true;
}
}

return false;
}

[/java]

Tuesday, June 12, 2012

MuPDF Android Library Build

Today I was able to successfully build MuPDF library on Windows 7 platform using Cygwin. I'll explain each and every step here.

1. Android SDK should be installed.

2. Android NDK should be installed

Just download android NDK here http://developer.android.com/sdk/ndk/index.html and extract it to a directory with no spaces in the name.

3. You need to install Cygwin latest version. download the setup.exe from http://cygwin.com/install.html and follow instructions here. do not skip a single step. Instructions :  http://vmerror.com/?p=133

4. Download MuPDF source zip file and third-party zip file here http://code.google.com/p/mupdf/downloads/list

5. Extract your mupdf source folder somewhere in your hard disk (path must not contain any spaces)

6. Create a folder named 'thirdparty' in the mupdf source folder you have extracted. It should be in the same level of 'android', 'apps', 'fitz', 'win32' etc. and extract downloaded thirdparty zip file directly under created folder.

7. You need to have Visual studio installed. if not you can download trial version here : http://www.microsoft.com/en-us/download/details.aspx?id=12752

Download and install it properly.

8. Go to mupdf source folder, open win32 folder and double click generated.vcproj

then it will open with visual studio.

9. In visual studio just run the c++ application. no need to have any visual studio or c++ knowledge. just press green arrow button (run button)

10. If everything goes ok, it should create a folder inside mupdf source. the folder name is 'generated' and it should contain some header files (.h files)

11. Open Cygwin console,(just double click cygwin installation short-cut) and type following command and enter.

 

cd /cygdrive/<path to mupdf sorce folder/android

ex. cd /cygdrive/c/mupdf-1.0-source/android

then

/cygdrive/<path to ndk installation>/ndk-build

ex. /cygdrive/c/ndk/ndk-build

 

Cheerz... thats all. now you have built your mupdf library and what you can do is, create an Android application using mupdf android source (inside android folder) run it and see...

you can create a library project and include it anywhere you need.

 

Install Cygwin to develop android NDK application

When you develop android native applications you need to have Unix tools. Cygwin emulates Unix environment on Windows. here I'm explaining how to install Cygwin step by step.

  • Download setup.exe from here : http://cygwin.com/install.html and execute it

  • Choose install from internet

  • When you specify installation location be sure to choose a directory path that contains no spaces in it

  • Choose a mirror site close to you

  • After you choose the mirror and click Next, Cygwin will download and present to you the list of available packages:

  • I suggest that we install the entire Devel branch. Click (once) on the word “Default” next to the root Devel node and wait few seconds while the setup hangs. When it is back, you will see that “Default” changes to “Install” for the Devel node. Then press next.

  • This might take long, may be half an hour or may be 1 - 3 hours depends on your internet connection. let it to be installed and create a short-cut on the desktop.


 

For detailed steps with screen shots please see step 2 in post below:

http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/

 

 

 

 

Monday, May 7, 2012

Solution: Android INSTALL_FAILED_INSUFFICIENT_STORAGE error Android Imulator

You need to increase the Android emulator's memory capacity, there are 2 ways for that:

1- Right click the root of your Android Project, go to "Run As" then go to "Run Configurations..." locate the "Android Application" node in the tree at the left, then select your project and go to the "Target" tab on the right side of the window look down for the "Additional Emulator Command Line Options" field (sometimes you'll need to make the window larger) and finally paste "-partition-size 1024" there. Click Apply and then Run to use your emulator.

2- Go to Eclipse's Preferences, then Select “Launch” Add “-partition-size 1024” on the “Default emulator option” field, then click “Apply” and use your emulator as usual.

 

Source : http://stackoverflow.com/questions/4709137/solution-android-install-failed-insufficient-storage-error

Tuesday, May 1, 2012

Pending Intent Extras Problem

http://stackoverflow.com/questions/4689029/send-extra-data-via-pendingintent-problem

Thursday, March 1, 2012

onConfigurationChanged is not being called

Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. Thus, if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must decalare android:configChanges="orientation|screenSiz e". However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

(From http://developer.android.com/guide/topics/resources/runtime-changes.html)