<tfoot id='OLyzU'></tfoot>

<legend id='OLyzU'><style id='OLyzU'><dir id='OLyzU'><q id='OLyzU'></q></dir></style></legend>
      • <bdo id='OLyzU'></bdo><ul id='OLyzU'></ul>

      <i id='OLyzU'><tr id='OLyzU'><dt id='OLyzU'><q id='OLyzU'><span id='OLyzU'><b id='OLyzU'><form id='OLyzU'><ins id='OLyzU'></ins><ul id='OLyzU'></ul><sub id='OLyzU'></sub></form><legend id='OLyzU'></legend><bdo id='OLyzU'><pre id='OLyzU'><center id='OLyzU'></center></pre></bdo></b><th id='OLyzU'></th></span></q></dt></tr></i><div id='OLyzU'><tfoot id='OLyzU'></tfoot><dl id='OLyzU'><fieldset id='OLyzU'></fieldset></dl></div>
    1. <small id='OLyzU'></small><noframes id='OLyzU'>

      如何使用 kivy、pyjnius 为 android 制作 GPS 应用程序

      时间:2023-09-01
      <tfoot id='0I3rl'></tfoot>

        <bdo id='0I3rl'></bdo><ul id='0I3rl'></ul>
      • <legend id='0I3rl'><style id='0I3rl'><dir id='0I3rl'><q id='0I3rl'></q></dir></style></legend>

        <small id='0I3rl'></small><noframes id='0I3rl'>

        1. <i id='0I3rl'><tr id='0I3rl'><dt id='0I3rl'><q id='0I3rl'><span id='0I3rl'><b id='0I3rl'><form id='0I3rl'><ins id='0I3rl'></ins><ul id='0I3rl'></ul><sub id='0I3rl'></sub></form><legend id='0I3rl'></legend><bdo id='0I3rl'><pre id='0I3rl'><center id='0I3rl'></center></pre></bdo></b><th id='0I3rl'></th></span></q></dt></tr></i><div id='0I3rl'><tfoot id='0I3rl'></tfoot><dl id='0I3rl'><fieldset id='0I3rl'></fieldset></dl></div>
              <tbody id='0I3rl'></tbody>

                本文介绍了如何使用 kivy、pyjnius 为 android 制作 GPS 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我是 KIVY、pyjnius 和 python-android 的新手.我需要为 android 制作简单的应用程序,它显示 GPS 坐标.但是,正如我所说,我是 kivy 和 pyforandroid 的新手.有人可以显示/给我示例,它在简单的 kivy-label-widget 中显示我的坐标吗?非常感谢!

                Im new in KIVY, pyjnius and python-android. I need to make simple app for android, which shows GPS coordinates. But, as i said, i'm new in kivy and pyforandroid. Can somebody show/give me example,which shows my coordinates in simple kivy-label-widget? Thanks a lot!

                我试过做这样的事情,但是......

                I ve tried to do something like this but...

                    package org.renpy.android;
                
                //import java.util.ArrayList;
                //import java.util.List;
                
                import android.location.Location;
                import android.location.LocationListener;
                import android.location.LocationManager;
                import android.content.Context;
                import android.os.Bundle;
                import android.os.Looper;
                import java.lang.Thread;
                import android.app.Activity;
                
                public class KivyGps {
                    LocationManager lm;
                    Thread gpsThread;
                    public long minDistance = 1;
                    public int  minTime = 1000;
                
                
                   static class KivyLocationListener implements LocationListener {
                
                    public Location lastLocation = new Location("Other");
                    //private List<LocationListener> listeners = new ArrayList<LocationListener>();
                
                    public void onLocationChanged(Location location) {
                        // TODO Auto-generated method stub
                        lastLocation = location;
                        //updateListeners(location);
                    }
                
                    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
                    }
                
                        // TODO Auto-generated method stub
                        return lastLocation;
                    }
                
                    }
                
                    static public KivyLocationListener locationListener = new KivyLocationListener();
                    public Thread init(final Activity currActivity) {
                
                        gpsThread = new Thread( new Runnable() {
                
                          public void run() {
                            try {
                                Looper.prepare();
                                 lm = (LocationManager) currActivity.getSystemService( Context.LOCATION_SERVICE );
                                 lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, minTime, minDistance, locationListener );
                                 Looper.loop();
                
                                }
                            catch ( Exception e ) {
                                e.printStackTrace();
                            }
                          }
                
                        } );
                        return gpsThread;    
                    }
                    //gpsThread.start();
                
                }
                

                在python中

                from jnius import autoclass
                
                LocationListener = autoclass('android.location.LocationListener')
                LocationManager = autoclass('android.location.LocationManager')
                LocationProvider = autoclass('android.location.LocationProvider')
                Location = autoclass('android.location.Location')
                Looper = autoclass('android.os.Looper')
                Context = autoclass('android.content.Context')
                KivyGps = autoclass('org.renpy.android.KivyGps')
                
                currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
                lm = currentActivity.getSystemService( Context.LOCATION_SERVICE)
                if lm.isProviderEnabled( LocationManager.GPS_PROVIDER ):
                    print 'CON GPS'
                
                else:
                    print 'SIN GPS'
                
                
                lps = lm.getAllProviders()
                for lp in lps.toArray():
                    print lp
                #Arreglar problema de derechos ACCESS_FINE_LOCATION en Kivy Launcher
                lp = lm.getProvider('gps')
                
                ll = KivyGps.locationListener
                kgps = KivyGps()
                gpsThread = kgps.init( currentActivity )
                gpsThread.start()
                
                loc = ll.getCurrentLocation()
                if loc:
                    print loc.getLatitude()
                    print loc.getLongitude()
                

                推荐答案

                我前段时间做了一个在 Kivy/pyjnius 中访问 GPS 的演示:

                I did while ago a demo of accessing GPS within Kivy/pyjnius:

                https://github.com/tito/android-demo

                看源码,什么都在里面.

                Look at the source code, everything is in it.

                这篇关于如何使用 kivy、pyjnius 为 android 制作 GPS 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Buildozer 构建失败:找不到 CC 的可执行文件 下一篇:Buildozer 编译 apk,但它在 android 上崩溃

                相关文章

                最新文章

                <small id='lSlS5'></small><noframes id='lSlS5'>

              1. <tfoot id='lSlS5'></tfoot>
                <i id='lSlS5'><tr id='lSlS5'><dt id='lSlS5'><q id='lSlS5'><span id='lSlS5'><b id='lSlS5'><form id='lSlS5'><ins id='lSlS5'></ins><ul id='lSlS5'></ul><sub id='lSlS5'></sub></form><legend id='lSlS5'></legend><bdo id='lSlS5'><pre id='lSlS5'><center id='lSlS5'></center></pre></bdo></b><th id='lSlS5'></th></span></q></dt></tr></i><div id='lSlS5'><tfoot id='lSlS5'></tfoot><dl id='lSlS5'><fieldset id='lSlS5'></fieldset></dl></div>

                <legend id='lSlS5'><style id='lSlS5'><dir id='lSlS5'><q id='lSlS5'></q></dir></style></legend>

                    • <bdo id='lSlS5'></bdo><ul id='lSlS5'></ul>