|
|
@ -576,21 +576,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setDefaultDataSubId(int subId) {
|
|
|
|
|
|
|
|
SubscriptionManager subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Method method = subscriptionManager.getClass().getDeclaredMethod("setDefaultDataSubId", int.class);
|
|
|
|
|
|
|
|
method.invoke(subscriptionManager, subId);
|
|
|
|
|
|
|
|
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
|
|
|
Method method1 = telephonyManager.getClass().getDeclaredMethod("setDataEnabled", boolean.class);
|
|
|
|
|
|
|
|
method1.invoke(telephonyManager, true);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
Log.e(TAG, "wjz debug setDefaultDataSubId: error is " + e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MicroPhotoContext.AppConfig retrieveAndSaveAppConfig() {
|
|
|
|
private MicroPhotoContext.AppConfig retrieveAndSaveAppConfig() {
|
|
|
|
MicroPhotoContext.AppConfig appConfig = new MicroPhotoContext.AppConfig();
|
|
|
|
MicroPhotoContext.AppConfig appConfig = new MicroPhotoContext.AppConfig();
|
|
|
|
|
|
|
|
|
|
|
@ -618,7 +603,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private MicroPhotoContext.AppConfig getAppConfig() {
|
|
|
|
private MicroPhotoContext.AppConfig getAppConfig() {
|
|
|
|
return MicroPhotoContext.getMpAppConfig(this.getApplicationContext());
|
|
|
|
return MicroPhotoContext.getMpAppConfig(getApplicationContext());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void saveAppConfig(MicroPhotoContext.AppConfig appConfig) {
|
|
|
|
private void saveAppConfig(MicroPhotoContext.AppConfig appConfig) {
|
|
|
@ -636,23 +621,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void gpsTake() {
|
|
|
|
|
|
|
|
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 注册位置监听器
|
|
|
|
|
|
|
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
|
|
|
|
|
|
|
|
Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
|
|
|
|
|
|
|
if (lastKnownLocation != null) {
|
|
|
|
|
|
|
|
double latitude = lastKnownLocation.getLatitude();
|
|
|
|
|
|
|
|
double longitude = lastKnownLocation.getLongitude();
|
|
|
|
|
|
|
|
// 处理最新位置信息
|
|
|
|
|
|
|
|
System.out.printf("gps" + latitude + "fds:" + longitude);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocationListener locationListener = new LocationListener() {
|
|
|
|
LocationListener locationListener = new LocationListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onLocationChanged(Location location) {
|
|
|
|
public void onLocationChanged(Location location) {
|
|
|
@ -676,83 +644,20 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
|
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
|
|
// 处理位置状态变化事件
|
|
|
|
// 处理位置状态变化事件
|
|
|
|
System.out.printf("fsdaf");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onProviderEnabled(String provider) {
|
|
|
|
public void onProviderEnabled(String provider) {
|
|
|
|
// 处理位置提供者启用事件
|
|
|
|
// 处理位置提供者启用事件
|
|
|
|
System.out.printf("fsdaf");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onProviderDisabled(String provider) {
|
|
|
|
public void onProviderDisabled(String provider) {
|
|
|
|
|
|
|
|
|
|
|
|
// 处理位置提供者禁用事件
|
|
|
|
// 处理位置提供者禁用事件
|
|
|
|
System.out.printf("fsdaf");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void startLocate() {
|
|
|
|
|
|
|
|
LocationManager mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
|
|
|
|
|
|
|
boolean providerEnabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
|
|
|
|
|
|
|
if (providerEnabled) { //GPS已开启
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 绑定监听
|
|
|
|
|
|
|
|
* 参数1,设备:有GPS_PROVIDER和NETWORK_PROVIDER两种,前者是GPS,后者是GPRS以及WIFI定位
|
|
|
|
|
|
|
|
* 参数2,位置信息更新周期.单位是毫秒
|
|
|
|
|
|
|
|
* 参数3,位置变化最小距离:当位置距离变化超过此值时,将更新位置信息
|
|
|
|
|
|
|
|
* 参数4,监听
|
|
|
|
|
|
|
|
* 备注:参数2和3,如果参数3不为0,则以参数3为准;参数3为0,则通过时间来定时更新;两者为0,则随时刷新
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, 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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Toast.makeText(this, "请打开GPS", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private void initSocket() {
|
|
|
|
|
|
|
|
// NettyChatClient nettyChatClient = NettyChatClient.newInstance("47.96.238.157", 6891);
|
|
|
|
|
|
|
|
//// NettyChatClient nettyChatClient = NettyChatClient.newInstance("180.166.218.222", 40032);
|
|
|
|
|
|
|
|
// nettyChatClient.init(new INettyMessageListener() {
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public void onReceive(String message) {
|
|
|
|
|
|
|
|
//// for (INettyMessageListener nettyMessageListener : mIMessageListenerList) {
|
|
|
|
|
|
|
|
//// nettyMessageListener.onReceive(message);
|
|
|
|
|
|
|
|
//// }
|
|
|
|
|
|
|
|
// System.out.println("dsfa");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public void onConnectSuccess() {
|
|
|
|
|
|
|
|
//// for (INettyMessageListener nettyMessageListener : mIMessageListenerList) {
|
|
|
|
|
|
|
|
//// nettyMessageListener.onConnectSuccess();
|
|
|
|
|
|
|
|
//// }
|
|
|
|
|
|
|
|
// System.out.println("dsfa");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public void onError() {
|
|
|
|
|
|
|
|
//// for (INettyMessageListener nettyMessageListener : mIMessageListenerList) {
|
|
|
|
|
|
|
|
//// nettyMessageListener.onError();
|
|
|
|
|
|
|
|
//// }
|
|
|
|
|
|
|
|
// System.out.println("dsfa");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// nettyChatClient.connect();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
|
|