Showing posts with label J2ME. Show all posts

How to get Latitude - Longitude without GPS in mobile device?

radar

What is GPS?
GPS stands for Global Positioning System. Its a hardware used to get the accurate location of device. It gives the Latitude - Longitude of the device.

What if there ain't GPS?
You might used Google Maps in non GPS device. They are still able to get the perfect location of your device. So we'll look into that situation how they target the mobile device. All you need is get below details from mobile device.

1. Mobile Country Code (MCC) - To detect current country of device.
2. Mobile Network Code (MNC)- Te delete current service provide.
3. Local Area Code (LAC)- To detect device in which region.
4. Cell ID - Unique id of that region.

I created GeoLocation class in javaQuery API 8.1 . I'm using free service to get the latitude and longitude. Sometime you may get 0.0 for Latitude and Longitude. It says that there is no record available for that details. This API is for testing purpose. If you are creating the paid application or Official application, buy service to get the latitude and longitude using mcc, mnc, lac and cellid. Let's take a look at code snippet.
/*
 * MAPTargetByMobile(int, int, int, int);
 * MAPTargetByMobile(mcc, mnc, lac, cellid);
 * It'll only give you Latitude and Longitude
*/
import javaQuery.importClass.javaQueryBundle;
import javaQuery.j2ee.GeoLocation;

public class Demo {
    public static void main(String[] args) throws IOException{
        GeoLocation Target = javaQueryBundle.createGeoLocation();
        Target.MAPTargetByMobile(404, 58, 1339, 9029);
        System.out.println(Target.Latitude);
        System.out.println(Target.Longitude);
    }
}
Now what next? 
Use Google Maps to get location of mobile device using Latitude and Longitude.

Related Article:
How to create mobile tracking application? [http://www.javaquery.com/2011/09/how-to-create-mobile-tracking.html]

How to create mobile tracking application?


How to create mobile tracking application for blackberry, android, etc... mobile device?

We all use mobile device and we worried about lost. f you are programmer than you can create the application to protect your device rather then buying the application. I'll give you idea about how you can use the logic to create that application.

I'm java programmer and now a days all device are using java. If you are Java Programmer then you can create it. I created this application for my "Blackberry" and i'll upload it asap on the site for free use. If you are geek and wanna create it you can easily create the application that makes your device secure. You should think about your device of 20-25k so please secure it.

All mobile in the world have four data available in it. Mobile company use it to provide network and detect where actually you are on the world. Even Google maps is using this data to show your location.

The Four data are:
1. Mobile Country Code (MCC) - To detect current country of device.
2. Mobile Network Code (MNC)- Te delete current service provide.
3. Local Area Code (LAC)- To detect device in which region.
4. Cell ID - Unique id of that region.

Step 1:
Store your current SIM number, Password to unlock the application, Recovery Contact in persistence memory.

Flow:
Mobile Start > Get current inserted SIM number > Match with SIM number stored in persistence memory
if(matched){
 // Ok show login box
}
else{
 // send msg to recovery contact with below details (MCC,MNC,LAC,Cell ID)
 // show login box
}
Extract all this data from device using java code.
/* Following code is for Blackberry */
int MCC = RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex());
int MNC = RadioInfo.getMNC(RadioInfo.getCurrentNetworkIndex());
int LAC = GPRSInfo.getCellInfo().getLAC();
int CELLID = GPRSInfo.getCellInfo().getCellId();
This is sample code for blackberry to get Mobile Country Code, Mobile Network Code, Local Area Code,Cell ID. You can do it for your device like(Android,blackberry,etc...).

Note: Some of you think if message comes from some number then you get idea that your mobile is with the number that sent you message and you can contact the service provider to locate and get your device back. But if you are developer then you have to provide service to users that shows location on some maps(Google Maps)

Step 2:
OR
Pass the above data to some free service provider. They will give you longitude and latitude. Get more information from:
Step 3: 
Use other site to display location using Latitude-Longitude.
http://www.google.co.in/search?sourceid=chrome&ie=UTF-8&q=location+using+latitude+longitude

For Developer:  Pass Latitude - Longitude to google maps http://code.google.com/apis/maps/index.html that will show you location.

How to put image in Dialog Box Blackberry?

Blackberry
Put image in blackberry dialog box. You may need it for custom icon or application logo. Lets check out how you can achieve this.

import jq.dialog.imgDialog;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;

public class Home extends UiApplication{
     MenuItem _imgDialog ;
  
     public Home() {
 Screen _s = new Screen();
 pushScreen(_s);
     }
     public static void main(String[] args) {
        Home _h = new Home();
 _h.enterEventDispatcher();
     } 
     public class Screen extends MainScreen{
 Screen(){
   setTitle("jq Developer");
   _imgDialog = new MenuItem("Image Dialog",0,0) {
     public void run() {
        imgDialog _iD = new imgDialog();
        int _result = _iD.doModal();
            }
   };
        addMenuItem(_imgDialog);
        }
     }
}
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.component.Dialog;

public class imgDialog extends Dialog{
 private static String choices[] = { "OK" };
 private static int values[] = { Dialog.OK };
    public imgDialog() {
     super("Java Query \nImage in Dialogbox",choices,values, Dialog.OK, Bitmap.getBitmapResource("jq.png"), Dialog.GLOBAL_STATUS);
    }
}
Project structure look like below:

Blackberry

Output:
Blackberry

How to create Blackberry Application?

Blackberry
I'm giving you the brief information to start develop your blackberry application. Creating blackberry application one need basic knowledge of JAVA. This is for those who are developing the application at professional level because it need API ($20).

Blackberry application developing tool provides all the thing so you don't need to remember method names of RIM( Research In Motion ) package.

Tools to start Developing application
  • - JDK (http://www.java.com)
  • - Eclipse (http://us.blackberry.com/developers/javaappdev/javaplugin.jsp)
  • - API set ($20) when you are developing at professional level. Application registration.

Step 1: Well start eclipse. 

Step 2: Create new project to start your development

Blackberry

Step 3: Name your project. Click finish

Blackberry

Creating first class file for your project. That will be the first page of your application.

Blackberry


Sample code:

package jq.screen;

import jq.dialog.imgDialog;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;

public class Home extends UiApplication{
      public Home() {
        Screen _s = new Screen();
        pushScreen(_s);
      }
      public static void main(String[] args) {
        Home _h = new Home();
        _h.enterEventDispatcher();
      }
      public class Screen extends MainScreen{
        Screen(){
        setTitle("javaQuery - Blackberry");
      }
}
Some important explanation of above code:
  • - extends UiApplication means that will be the first class file and it'll start Blackberry application
  • - Screen extends MainScreen means the screen that displayed on application run mode.
  • setTitle("javaQuery - Blackberry") means set Title of the application

Run your application by right clicking on the project > Run as