Context.PROVIDER_URL的写法

WebSphere:             
Context.INITIAL_CONTEXT_FACTORY             
  "com.ibm.websphere.naming.WsnInitialContextFactory         "             
Context.PROVIDER_URL             
  "iiop://localhost:900         "             
  
  
Weblogic:             
Context.INITIAL_CONTEXT_FACTORY             
          "weblogic.jndi.WLInitialContextFactory         "             
Context.PROVIDER_URL             
          "t3://127.0.0.1:7001         "                                                               
      
          J2EE         SDK(J2EE         RI):             
Context.INITIAL_CONTEXT_FACTORY             
          "com.sun.jndi.cosnaming.CNCtxFactory         "             
Context.PROVIDER_URL             
          "iiop://127.0.0.1:1050         "             
      
SilverStream:             
Context.INITIAL_CONTEXT_FACTORY             
  "com.sssw.rt.jndi.AgInitCtxFactory         "             
Context.PROVIDER_URL             
  "sssw://localhost:80         "             
  
      
          
OC4J     
Context.INITIAL_CONTEXT_FACTORY     
"com.evermind.server.rmi.RMIInitialContextFactory "     
Context.PROVIDER_URL     
"ormi://127.0.0.1/ "     
  
          
      
  
  
JBOSS的:     
java.naming.factory.initial     
"org.jnp.interfaces.NamingContextFactory "     
java.naming.provider.url     
"localhost:1099 "     
  
          
  
          
WAS5:     
Context.INITIAL_CONTEXT_FACTORY             
  "com.ibm.websphere.naming.WsnInitialContextFactory         "             
Context.PROVIDER_URL             
  "iiop://localhost:2809"  
`getSystemService(Context.LOCATION_SERVICE)` 是 Android 开发中常用的方法,用于获取与位置服务相关的系统服务实例。通过这个方法,开发者可以访问设备的定位功能,例如 GPS、Wi-Fi 和移动网络等。 以下是一些关键点: 1. **方法签名**: ```java LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); ``` 2. **参数**: - `Context.LOCATION_SERVICE`:这是一个常量,表示要获取的位置服务。 3. **返回类型**: - 返回一个 `LocationManager` 对象,通过这个对象可以访问设备的定位功能。 4. **使用场景**: - 获取位置信息,例如获取当前设备的经纬度。 - 监听位置变化,例如实时更新设备的位置。 5. **权限**: - 使用位置服务需要在 `AndroidManifest.xml` 中声明相关权限,例如 `ACCESS_FINE_LOCATION` 和 `ACCESS_COARSE_LOCATION`。 以下是一个简单的示例,演示如何获取 `LocationManager` 并获取当前位置: ```java import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationManager; import androidx.core.app.ActivityCompat; public class LocationUtils { public static Location getCurrentLocation(Context context) { LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return null; } Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location == null) { location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } return location; } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值