A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Mobile
»
Android
Author
shows me blank with blinking arrow
sameera liyanage
Ranch Hand
Joined: Nov 25, 2008
Posts: 643
posted
Nov 23, 2011 04:04:39
0
This is my main class
package com.aruna.location; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.telephony.TelephonyManager; import android.telephony.gsm.GsmCellLocation; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class CellID extends Activity implements OnClickListener{ GsmCellLocation location; int cellID, lac; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); location = (GsmCellLocation) tm.getCellLocation(); cellID = location.getCid(); lac = location.getLac(); Button bt=(Button)findViewById(R.id.displayMap); bt.setOnClickListener(this); } private boolean displayMap(int cellID, int lac) throws Exception { String urlString = "http://www.google.com/glm/mmap"; //---open a connection to Google Maps API--- URL url = new URL(urlString); URLConnection conn = url.openConnection(); HttpURLConnection httpConn = (HttpURLConnection) conn; httpConn.setRequestMethod("POST"); httpConn.setDoOutput(true); httpConn.setDoInput(true); httpConn.connect(); //---write some custom data to Google Maps API--- OutputStream outputStream = httpConn.getOutputStream(); WriteData(outputStream, cellID, lac); //---get the response--- InputStream inputStream = httpConn.getInputStream(); DataInputStream dataInputStream = new DataInputStream(inputStream); //---interpret the response obtained--- dataInputStream.readShort(); dataInputStream.readByte(); int code = dataInputStream.readInt(); if (code == 0) { double lat = (double) dataInputStream.readInt() / 1000000D; double lng = (double) dataInputStream.readInt() / 1000000D; dataInputStream.readInt(); dataInputStream.readInt(); dataInputStream.readUTF(); //---display Google Maps--- String uriString = "geo:" + lat + "," + lng; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uriString)); startActivity(intent); return true; } else { return false; } } private void WriteData(OutputStream out, int cellID, int lac) throws IOException { DataOutputStream dataOutputStream = new DataOutputStream(out); dataOutputStream.writeShort(21); dataOutputStream.writeLong(0); dataOutputStream.writeUTF("en"); dataOutputStream.writeUTF("Android"); dataOutputStream.writeUTF("1.0"); dataOutputStream.writeUTF("Web"); dataOutputStream.writeByte(27); dataOutputStream.writeInt(0); dataOutputStream.writeInt(0); dataOutputStream.writeInt(3); dataOutputStream.writeUTF(""); dataOutputStream.writeInt(cellID); dataOutputStream.writeInt(lac); dataOutputStream.writeInt(0); dataOutputStream.writeInt(0); dataOutputStream.writeInt(0); dataOutputStream.writeInt(0); dataOutputStream.flush(); } @Override public void onClick(View v) { try { displayMap(cellID, lac); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
this is my main xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/displayMap" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Display map of current location" /> <TextView android:id="@+id/status" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
this is my manifest file
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aruna.location" android:versionCode="1" android:versionName="1.0"> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".CellID" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
this is working fine.But after clicking the button it gives me blank screen with blinking arrow.See the attachment.
screenshot_2011-11-23_1632.png
sameera liyanage
Ranch Hand
Joined: Nov 25, 2008
Posts: 643
posted
Nov 26, 2011 07:31:24
0
can anyone help me ?
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: shows me blank with blinking arrow
Similar Threads
url error ,please help
How to retrieve string from EditText?
it doesn't shows location details
android.os.networkonmainthreadexception
telephonyManager.getCellLocation() gives null
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter