Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8194035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:41:06+00:00 2026-06-07T04:41:06+00:00

I have a problem with an application that sends coordinates via SMS. When I

  • 0

I have a problem with an application that sends coordinates via SMS.
When I added the battery level, the application stopped working after catching the fix.
(Coordinates not on display, but they are via SMS.)

Please help.

ZoltrixGPSActivity

package com.zoltrix.gps;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ZoltrixGPSActivity extends Activity {

    // Here I added a level of battery (1)

    private TextView contentTxt;
    private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent intent) {
            // TODO Auto-generated method stub
            int level = intent.getIntExtra("level", 0);
            contentTxt.setText(String.valueOf(level) + "%");
        }
    };

    // end

    TextView textLat;
    TextView textLong;
    TextView textAlt;
    TextView textPro;
    TextView textAcc;
    TextView textSpeed;
    public String onLocat;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Here I added a level of battery (2)

        contentTxt = (TextView) this.findViewById(R.id.battery);
        this.registerReceiver(this.mBatInfoReceiver, new IntentFilter(
                Intent.ACTION_BATTERY_CHANGED));

        // end

        Button btn1 = (Button) findViewById(R.id.buttonExit);
        btn1.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // exit
                finish();
                System.exit(0);
            }
        });

        textLat = (TextView) findViewById(R.id.textLat);
        textLong = (TextView) findViewById(R.id.textLong);
        textAlt = (TextView) findViewById(R.id.textAlt);
        textPro = (TextView) findViewById(R.id.textPro);
        textAcc = (TextView) findViewById(R.id.textAcc);
        textSpeed = (TextView) findViewById(R.id.textSpeed);

        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        LocationListener ll = new mylocationlistener();
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
    }

    class mylocationlistener implements LocationListener {

        public void onLocationChanged(Location location) {
            if (location != null) {
                double pLong = location.getLongitude();
                double pLat = location.getLatitude();
                double pAlt = location.getAltitude();
                String PPro = location.getProvider();
                float PAcc = location.getAccuracy();
                float PSpeed = location.getSpeed();

                textLat.setText(Double.toString(pLat));
                textLong.setText(Double.toString(pLong));
                textAlt.setText(Double.toString(pAlt));
                textPro.setText(PPro);
                textAcc.setText(Float.toString(PAcc));
                textSpeed.setText(Double.toString(PSpeed));

                Intent i = new Intent(ZoltrixGPSActivity.this,
                        SendSMSActivity.class);
                i.putExtra("lon", Double.toString(pLong));
                i.putExtra("lat", Double.toString(pLat));
                i.putExtra("alt", Double.toString(pAlt));
                i.putExtra("acc", Float.toString(PAcc));
                i.putExtra("spe", Float.toString(PSpeed));
                startActivity(i);

            }

        }

        public void onProviderDisabled(String provider) {
            // TODO Auto-generated method stub

        }

        public void onProviderEnabled(String provider) {
            // TODO Auto-generated method stub

        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
            // TODO Auto-generated method stub

        }

    }

}

SendSMSActivity

package com.zoltrix.gps;

import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;

public class SendSMSActivity extends Activity {
    Button btnSendSMS;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
        btnSendSMS.setOnClickListener(new View.OnClickListener()

        {

            public void onClick(View v) {

                Bundle extras = getIntent().getExtras();

                String LON = extras.getString("lon");
                String LAT = extras.getString("lat");
                String ALT = extras.getString("alt");
                String ACC = extras.getString("acc");
                String SPE = extras.getString("spe");

                sendSMS("510104727", "LON" + LON + "#" + "LAT" + LAT + "#"
                        + "ALT" + ALT + "#" + "ACC" + ACC + "#" + "SPE" + SPE);
            }

        });
    }

    // ---sends an SMS message to another device---
    private void sendSMS(String phoneNumber, String message) {
        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, null, null);
    }

}

Manifest

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

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

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.SEND_SMS" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="com.zoltrix.gps.SendSMSActivity"
            android:label="@string/app_name" >
        </activity>
        <activity
            android:name="com.zoltrix.gps.ZoltrixGPSActivity"
            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>

Loyout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="top"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Latitude"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/textLat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Longitude "
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/textLong"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Alt"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/textAlt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Provider"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/textPro"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Accuracy (m)" />

    <TextView
        android:id="@+id/textAcc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/text344"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Speed (m/s)" />

    <TextView
        android:id="@+id/textSpeed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/battery"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />




    <Button
        android:id="@+id/btnSendSMS"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Send" />

    <Button
        android:id="@+id/buttonExit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Exit" />

</LinearLayout>

LogCat
http://pastebin.com/whhdHsyw

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:41:08+00:00Added an answer on June 7, 2026 at 4:41 am

    Try adding the android.permission.BATTERY_STATS permission to your code.

    <uses-permission android:name="android.permission.BATTERY_STATS" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that sends a single sms to multiple numbers via
I have C# application that sends an XML document to a server via HTTPS
I have a problem with the esmtp application that I really hope you help
I have a problem, that I can't solve. I am writing an application that
I have a problem regarding Android App. I have created an application that download
The problem: we have one application that has a portion which is used by
Problem I have a UDPlistener application that I need to write a unit test
Here's the core problem: I have a .NET application that is using COM interop
I have a problem with my android application. That application which uses the kSOAP
So here is the problem: I have some logic in my application that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.