Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > Android - คือผมต้องการแสดงค่า lat = location.getLatitude(); และ lon = location.getLongitude(); ไปใน newIntent.putExtra



 

Android - คือผมต้องการแสดงค่า lat = location.getLatitude(); และ lon = location.getLongitude(); ไปใน newIntent.putExtra

 



Topic : 106368



โพสกระทู้ ( 17 )
บทความ ( 0 )



สถานะออฟไลน์




คือผมต้องการแสดงค่า lat = location.getLatitude(); และ lon = location.getLongitude(); ไปใน newIntent.putExtra("sms_body", sb.toString()+"ขอความช่วยเหลือจากพิกัดlatitude"+lat+"longitude"+lon);อะครับ แต่ค่าตำแหน่งมันไม่ออกอะครับ พอมีวิธีแก้ไหมครับ ขอบคุณครับ

Code (Android-Java)
package com.demogps.demogps;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;


public class EmergencyMessages extends Activity {
    	  EditText etPhoneNumber, etMessage;
    	  //Button btnSend;
    	  public double lat;
    	  public double lon;
    	  public LocationManager locationManager;
    	  //public TextView txtLat;
    	  //public TextView txtLon;
    	  //public TextView Detail;
    	  
    	  public P_myProfileDATA mHelper;
    	  public TextView output;
    	  
    	  public M_myMemDATA mHelper1;
    	  public TextView txtNum;
    	  
    	  String separator = "; ";
    	    public void onCreate(Bundle savedInstanceState) {
    	        super.onCreate(savedInstanceState);
    	        requestWindowFeature(Window.FEATURE_NO_TITLE);
    	        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
    	        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    	        setContentView(R.layout.activity_emergency_messages);

    	        etPhoneNumber = (EditText)findViewById(R.id.txtPhoneNo);
    	        etMessage = (EditText)findViewById(R.id.txtMessage);
    	        //txtLat = (TextView)findViewById(R.id.txtLat);
    	        //txtLon = (TextView)findViewById(R.id.txtLon);
    	        
    	        
    	        
    	        output = (TextView)findViewById(R.id.txtOutput);
    			this.output = (TextView) this.findViewById(R.id.txtOutput);
    			this.mHelper = new P_myProfileDATA(this);
    			List<String> names = this.mHelper.selectAll();
    	        final StringBuilder sb = new StringBuilder();
    	        for (String name : names) {
    	           sb.append(name);
    	        }
    	        Log.d("EXAMPLE", "names size - " + names.size());
    	        this.output.setText(sb.toString());
    	        
    	        
    	        txtNum = (TextView)findViewById(R.id.txtNum);
    			this.txtNum = (TextView) this.findViewById(R.id.txtNum);
    			this.mHelper1 = new M_myMemDATA(this);
    			List<String> members = this.mHelper1.selectAll();
    	        final StringBuilder sb11 = new StringBuilder();
    	        for (String name1 : members) {
    	           sb11.append(separator+name1);
    	        }
    	        Log.d("EXAMPLE", "members size - " + members.size());
    	       
    	        //this.txtNum.setText(sb11.toString());

    	        etPhoneNumber.setText(sb11.toString());
    	      
    	    	//จัดการ Event ต่างๆ ของ Location
    	        LocationListener locationListener = new LocationListener(){
    	 
    	            //เมื่อหาตำแหน่งได้ จะทำงานที่ function นี้
    	            public void onLocationChanged(Location location) {
    	                // TODO Auto-generated method stub
    	            		  
    	                //รับค่า Latitude และ Longitude จาก location
    	                lat = location.getLatitude();
    	                lon = location.getLongitude();
    	           
    	                //ทำการแสดงค่า Latitude และ Longitude ที่ได้รับมา
    	                //txtLat.setText("Latitude : " + lat);
    	                //txtLon.setText("Longitude : " + lon); 
 	      		     
    	            }

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

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

					@Override
					public void onStatusChanged(String provider, int status, Bundle extras) {
						// TODO Auto-generated method stub
						
					}
    	            	
    	 
    	        };
    	        
    	      //สร้าง locationManager เพื่อใช้ในการรับตำแหน่ง
    	        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    	 
    	        //ระบุรูปแบบของตำแหน่งที่เราต้องการ และเชื่อมกับ locationListener
    	        //LocationManager.GPS_PROVIDER รับตำแหน่งจาก GPS
    	        //LocationManager.NETWORK_PROVIDER รับตำแหน่งจาก Network พวก Wifi EDGE GPRS 3G
    	        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
    	        
    	       /*etPhoneNumber.setText(sb1.toString());*/
    	        
    	       /* btnSend.setOnClickListener(new OnClickListener() {
    	            public void onClick(View v) {
    	                String phoneNumber = etPhoneNumber.getText().toString();
    	                String message = etMessage.getText().toString();
    	                if(phoneNumber.length() != 0 && message.length() != 0) {
    	                    sendSMS(phoneNumber, message);
    	                    etPhoneNumber.setText("");
    	                    etPhoneNumber.requestFocus();
    	                    etMessage.setText("");
    	                    Toast.makeText(getApplicationContext()
    	                            , "Message has sent"
    	                            , Toast.LENGTH_SHORT).show();
    	                } else {
    	                    Toast.makeText(getApplicationContext()
    	                            , "Please enter phone number and message"
    	                            , Toast.LENGTH_SHORT).show();
    	                }
    	            }
    	        });*/
    	        
    	     Intent newIntent = new Intent(Intent.ACTION_VIEW);
   		     newIntent.putExtra("address", sb11.toString());  // Default Address to
   		     newIntent.putExtra("sms_body", sb.toString()+"ขอความช่วยเหลือจากพิกัดlatitude"+lat+"longitude"+lon); // Default Message
   		     newIntent.setType("vnd.android-dir/mms-sms");
   		     startActivity(newIntent);

    	    }
    	    
    	    /*public void sendSMS(String phoneNumber, String message) {
    	        SmsManager sms = SmsManager.getDefault();
    	        sms.sendTextMessage(phoneNumber, null, message, null, null);
    	    }*/
    	}


รูปที่ไม่แสดงค่า
imag



Tag : Mobile, Android







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-02-28 12:15:24 By : Itinon2010 View : 1396 Reply : 2
 

 

No. 1



โพสกระทู้ ( 308 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook Blogger

ลองแบบนี้ดูมั้ยครับ

http://www.tutordroid.com/%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5-get-location-%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B9%80%E0%B8%A3%E0%B8%B2%E0%B8%AD%E0%B8%A2%E0%B8%B9%E0%B9%88%E0%B9%82%E0%B8%94%E0%B8%A2%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%9E%E0%B8%B4%E0%B8%81%E0%B8%B1%E0%B8%94-gps-android-get-location/






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-01 14:06:23 By : tutordroid.com
 


 

No. 2



โพสกระทู้ ( 17 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณมากๆเลยครับ ^^
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-01 22:41:59 By : Itinon2010
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Android - คือผมต้องการแสดงค่า lat = location.getLatitude(); และ lon = location.getLongitude(); ไปใน newIntent.putExtra
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่