Android:关闭VM:manifest.xml中的问题

时间:2014-07-24 10:53:29

标签: android

嗨朋友我在安装我的应用时遇到问题。

我是android编程的初学者。我构建了一个程序来获取位置并将其与我在代码中给出的位置进行比较。但是执行它时没有显示任何内容,应用程序会自动关闭。我正在粘贴代码和LOGCAT。我无法找到错误。

作为一个初学者,我很难找到错误。所以论坛是我最后的希望,我希望那里的人肯定会帮助我解决这个问题。

 public class MainActivity extends ActionBarActivity {

        public EditText text1;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
           text1 =(EditText) findViewById(R.id.text1);
            Intent intent = new Intent(this, TrackService.class);

            startService(intent);
    }

        @Override
        protected void onResume() {
            // TODO Auto-generated method stub
            super.onResume();
            finish();
        }


    }

我怀疑我的manifest.xml存在一些问题...我不知道它只是一个猜测...如果有人帮我解决这个问题会很好... TY

  public class TrackService extends IntentService implements LocationListener,
                        GooglePlayServicesClient.ConnectionCallbacks,
                        GooglePlayServicesClient.OnConnectionFailedListener {
                    private Context context;
                    String Lat, Long;

                    private LocationRequest mLocationRequest;

                    private LocationClient mLocationClient;


                    public TrackService() {
                        super("Trackservice"); 

                         }



    @Override
                        public void onCreate() {
                            super.onCreate();
                            mLocationRequest = LocationRequest.create();
                            context = getApplicationContext();
                            mLocationRequest.setInterval(1000 * 60 * 2);// Every 2 minute
                            mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

                            mLocationRequest
                                    .setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);
                            mLocationClient = new LocationClient(this, this, this);

                        @Override
                        public void onConnected(Bundle bundle) {

                            startPeriodicUpdates();

                        }
                        @Override
                        public void onLocationChanged(Location location) {
                            System.out.println(location.getLatitude() + " "+ location.getLongitude());
                            Lat = location.getLatitude() + "";
                            Long = location.getLongitude() + "";
                            if (isConnectingToInternet()){
                                String Text = "My current location is: " +"Latitud = " + location.getLatitude() +"Longitud = " + location.getLongitude();
                                Toast.makeText(getApplicationContext(),Text,Toast.LENGTH_SHORT).show();


                            }
                            }
                        private void startPeriodicUpdates() {

                            mLocationClient.requestLocationUpdates(mLocationRequest, this);

                        }
                        private void stopPeriodicUpdates() {
                            mLocationClient.removeLocationUpdates(this);

                        }
                        @Override
                        public IBinder onBind(Intent intent) {

                            return null;
                        }


                        @Override
                        protected void onHandleIntent(Intent intent) {
                            // TODO Auto-generated method stub

                        }
                    public boolean isConnectingToInternet() {
                            ConnectivityManager connectivity = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
                            if (connectivity != null) {
                                NetworkInfo[] info = connectivity.getAllNetworkInfo();
                                if (info != null)

                    for (int i = 0; i < info.length; i++)
                                        if (info[i].getState() == NetworkInfo.State.CONNECTED) {
                                        return true;
                                        }

                            }
                            return false;
                        }

                    public class UploadLocationInfo extends AsyncTask<Void, Void, Void> {


                            @Override
                            protected Void doInBackground(Void... params) {


                                double x = Double.parseDouble(Long);
                                double y = Double.parseDouble(Lat);
                                String Text = "My current location is: " +"Latitud = " + Lat +"Longitud = " + Long;
                                Toast.makeText(getApplicationContext(),Text,Toast.LENGTH_SHORT).show();
                                double a = 48.6800000;
                                double b = 2.2100000;  
                                float[] results = new float[1];
                                Location.distanceBetween(y, x, b, a, results);
                                float distanceInMeters = results[0];
                                boolean isWithin10m = false;
                                if( distanceInMeters < 20)
                                {
                                 isWithin10m = true;
                                }

                                System.out.println("Uploading New Location");

                               if(isWithin10m){

                                try {
                                    //open a web page


                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                }else{

                                }
                                return null;

                            }
                        }

                        @Override
                        public void onConnectionFailed(ConnectionResult arg0) {
                        }
                 @Override
                        public void onDisconnected() {

                        }

                    }

的Manifest.xml ............................................ .................................................. ................................................. < / p>

            <?xml version="1.0" encoding="utf-8"?>
            <manifest xmlns:android="http://schemas.android.com/apk/res/android"
                package="com.example.mobiletrackerslave"
                android:versionCode="1"
                android:versionName="1.0" >

                <uses-sdk
                    android:minSdkVersion="8"
                    android:targetSdkVersion="19" />

                <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
                <uses-permission android:name="android.permission.INTERNET"/>
                <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
                <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

                <application
                    android:allowBackup="true"
                    android:icon="@drawable/ic_launcher"
                    android:label="@string/app_name"
                    android:theme="@style/AppTheme" >
                    <activity
                        android:name="com.example.mobiletrackerslave.MainActivity"
                        android:label="@string/app_name" >
                        <intent-filter>
                            <action android:name="android.intent.action.MAIN" />

                            <category android:name="android.intent.category.LAUNCHER" />
                        </intent-filter>
                    </activity>
                    <service android:name="com.example.mobiletrackerslave.TrackService" ></service> 
                </application>

            </manifest>

logcat的.............................................. .................................................. .................................................. ..

           07-24 13:23:19.809: D/AndroidRuntime(8000): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
    07-24 13:23:19.809: D/AndroidRuntime(8000): CheckJNI is OFF
    07-24 13:23:19.809: D/dalvikvm(8000): Trying to load lib libjavacore.so 0x0
    07-24 13:23:19.819: D/dalvikvm(8000): Added shared lib libjavacore.so 0x0
    07-24 13:23:19.819: D/dalvikvm(8000): Trying to load lib libnativehelper.so 0x0
    07-24 13:23:19.819: D/dalvikvm(8000): Added shared lib libnativehelper.so 0x0
    07-24 13:23:19.960: D/AndroidRuntime(8000): Calling main entry com.android.commands.pm.Pm
    07-24 13:23:19.960: D/AndroidRuntime(8000): Shutting down VM
    07-24 13:23:19.970: D/dalvikvm(8000): GC_CONCURRENT freed 95K, 18% free 469K/568K, paused 2ms+1ms, total 10ms
    07-24 13:23:19.980: D/jdwp(8000): Got wake-up signal, bailing out of select
    07-24 13:23:19.980: D/dalvikvm(8000): Debugger has detached; object registry had 1 entries
    07-24 13:23:20.370: D/AndroidRuntime(8016): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
    07-24 13:23:20.370: D/AndroidRuntime(8016): CheckJNI is OFF
    07-24 13:23:20.380: D/dalvikvm(8016): Trying to load lib libjavacore.so 0x0
    07-24 13:23:20.380: D/dalvikvm(8016): Added shared lib libjavacore.so 0x0
    07-24 13:23:20.400: D/dalvikvm(8016): Trying to load lib libnativehelper.so 0x0
    07-24 13:23:20.400: D/dalvikvm(8016): Added shared lib libnativehelper.so 0x0
    07-24 13:23:20.530: D/AndroidRuntime(8016): Calling main entry com.android.commands.am.Am
    07-24 13:23:20.540: D/dalvikvm(8016): Note: class Landroid/app/ActivityManagerNative; has 157 unimplemented (abstract) methods
    07-24 13:23:20.540: I/ActivityManager(523): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.mobiletrackerslave/.MainActivity} from pid 8016
    07-24 13:23:20.570: D/AndroidRuntime(8016): Shutting down VM
    07-24 13:23:20.570: D/dalvikvm(8016): GC_CONCURRENT freed 97K, 17% free 500K/600K, paused 1ms+0ms, total 3ms
    07-24 13:23:20.570: D/jdwp(8016): Got wake-up signal, bailing out of select
    07-24 13:23:20.570: D/dalvikvm(8016): Debugger has detached; object registry had 1 entries
    07-24 13:23:20.580: D/dalvikvm(8027): Late-enabling CheckJNI
    07-24 13:23:20.580: I/ActivityManager(523): Start proc com.example.mobiletrackerslave for activity com.example.mobiletrackerslave/.MainActivity: pid=8027 uid=10085 gids={50085, 3003, 1028}
    07-24 13:23:20.610: D/overlay(160): Set pipe=RGB1 dpy=0; Set pipe=VG0 dpy=0; Set pipe=VG1 dpy=0; 
    07-24 13:23:20.700: D/overlay(160): Unset pipe=VG0 dpy=0; Unset pipe=VG1 dpy=0; Unset pipe=RGB1 dpy=0; 
    07-24 13:23:20.780: D/overlay(160): Set pipe=RGB1 dpy=0; Set pipe=VG0 dpy=0; 
    07-24 13:23:20.790: D/overlay(160): Unset pipe=VG0 dpy=0; Unset pipe=RGB1 dpy=0; 
    07-24 13:23:20.811: W/InputMethodManagerService(523): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@429da6d8 attribute=android.view.inputmethod.EditorInfo@429da6e8, token = android.os.BinderProxy@41ff6620
    07-24 13:23:20.851: D/overlay(160): Set pipe=RGB1 dpy=0; Set pipe=VG0 dpy=0; Set pipe=VG1 dpy=0; 
    07-24 13:23:22.632: D/overlay(160): Unset pipe=VG0 dpy=0; Unset pipe=VG1 dpy=0; Unset pipe=RGB1 dpy=0; 

0 个答案:

没有答案