Pages

Tuesday 10 May 2011

J2me run an android using Netbeans IDE



If you want  J2ME code was run an android  just follow the steps

Step 1:
First Create Android Application (  Netbeans Configure with Android  )

Step 2:


    <?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.me.list">
    <application>
         <activity android:name=".SearchListActivity" android:label="SearchListActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>


 
To be able to use the vibrator you have to add the following tag to your
            AndroidManifest.xml file:
            <uses-permission android:name="android.permission.VIBRATE" />

            In some special cases, you may want to bypass restarting of your activity
            based on one or more types of configuration changes. This is done with
             the android:configChanges attribute in its manifest. For any types of
               configuration changes you say that you handle there, you will receive a
               call to your current activity's onConfigurationChanged(Configuration)
              method instead of being restarted. If a configuration change involves any
              that you do not handle, however, the activity will still be restarted and
               onConfigurationChanged(Configuration) will not be called."          
               interesting info on 'sensor' orientation detection (or the lack of ..)
             http://androidguys.com/?p=2914
              
              I strongly suggest using the following attribute within the <activity/> tag in the
              AndroidManifext.xml file:
             
              android:configChanges="keyboardHidden|orientation"
                // http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html
     The virtual keyboard behavior can be configured from the AndroidManifest.xml file.  For example:
     <activity name="myactivity"
        android:windowSoftInputMode="adjustResize">
        ...
    </activity>
    This will shrink the LWUIT form once the keyboard appears.  By default the keyboard will be shown on top
    it seems.

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"  android:versionCode="1"
          android:versionName="1.0.0"
               package="org.me.list">
    <application>
        <activity android:name=".SearchListActivity " android:screenOrientation="sensor" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="stateVisible|adjustResize"  android:label="SearchListActivity ">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <uses-permission android:name="android.permission.VIBRATE" />

            </intent-filter>
        </activity>
    </application>
</manifest>

Step 3:
Create Assets( we wanted to add some resources in the assets directory for use an Android Application if you not create assets raise File not found exception)
  1. Create a directory called ‘assets’ at your project root (same dir that AndroidManifest.xml lives)
  2. In /nbproject/project.properties, change
assets.dir=
to
 assets.dir=assets
assets.available=true
asset.dir=assets
  1. In /nbproject/build-impl.xml, there is line in the “if=assets.available” target that reads
4.      <arg value="${asset.dir}"/>
that needs to be changed to
<arg value="${assets.dir}"/>
That’s it – you should be all set and “file:///android_asset/” should be accessible to your application and contain the contents of your project’s assets directory.

Step 4:
1.Download Code from  following Link4Source copy  that files and load to the Src directory
2.Find Src\org\meteoroid\test\ and load ur J2ME MIDlet File and supported Files
Chage ActivityName,Package name in AndroidManifest.xml
3.Set MIDlet File location on assets\META-INF\MANIFEST-MF change
MIDlet-1: MIDlet_Title,/icon.png,org.App.test.MainMidlet
MIDlet-2: Canvas,/icon.png,org.App.test.TestMIDlet2
.
.
.
4.Load image,Txt,and other resources to load in Assets
Step 5:
Build Android Appliaction,then Run the Appliaction

No comments:

Post a Comment