我想知道如何捕捉事件或什么时候我的LocationReqest过期,继承人代码,然后我称之为
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setExpirationDuration(500);
mLocationRequest.setNumUpdates(1);
mLocationClient.requestLocationUpdates(mLocationRequest, this);
Run Code Online (Sandbox Code Playgroud)
现在我需要知道我的LocationRequest是休息,ty求助:)
编辑
我以为我能抓住它
public void onLocationChanged(Location location) {
//something is here
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用:(
EDIT2
我部分解决了它通过添加处理程序检查N + 500ms如果位置设置,我仍然想知道我是否可以没有处理程序
我想将 ActionBar 隐藏在我的一个片段中,但是当我打电话时
((MainActivity) getActivity()).getActionBar().hide();
在片段上我得到这样的东西
如何删除该空白并使其“全屏” - 我希望显示通知栏
[编辑:]
最低 SDK 不是 4.0,但当我启动这个应用程序时,我将其设置为 2.3,我必须使用 appcompant
主要活动 xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context="com.mariusz.myapp.MainActivity" >
<!--
As the main content view, the view below consumes the entire
space available using match_parent in both dimensions.
-->
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?android:attr/actionBarSize" />
<!--
android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If …
Run Code Online (Sandbox Code Playgroud) 我设置了模拟位置,但是在启用模拟模式时我无法接收任何位置,通常我每3秒接收一次位置并更新位置 - 当模拟模式被禁用时 - 但是使用模拟模式启用我无法获得任何位置
@Override
public void onConnected(Bundle bundle) {
Utils.printDebug("onConnected");
Location mockLocation = new Location("network");
mockLocation.setLatitude(50.120089);
mockLocation.setLongitude(18.993206);
mockLocation.setAccuracy(4.0f);
mockLocation.setTime(System.currentTimeMillis());
LocationServices.FusedLocationApi.setMockMode(mGoogleApiClient, true);
LocationServices.FusedLocationApi.setMockLocation(mGoogleApiClient, mockLocation);
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
mGoogleApiClient);
if(mLastLocation!=null)
Utils.showToast(getApplicationContext(), "Last know location is " + mLastLocation.getLatitude() + ", " + mLastLocation.getLongitude());
startLocationUpdates();
}
Run Code Online (Sandbox Code Playgroud)
我有<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
和开发人员选项模拟位置启用.
我怎样才能收到那个模拟位置?
我想在预装M设备上将AES密钥存储在AndroidKeyStore中
我试图使用生成的密钥 KeyGenerator
KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES);
keyGen.init(256);
SecretKey secretKey = keyGen.generateKey();
Run Code Online (Sandbox Code Playgroud)
但我无法从KeyStore访问该密钥,后来我尝试使用 KeyPairGenerator
KeyPairGenerator kpg = KeyPairGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
kpg.initialize(new KeyPairGeneratorSpec.Builder(this)
.setAlias("alias")
.build());
KeyPair kp = kpg.genKeyPair();
Run Code Online (Sandbox Code Playgroud)
但
java.security.NoSuchAlgorithmException:未找到KeyPairGenerator AES实现
我写了启动器活动,有选项显示或隐藏壁纸,我使用两个主题
机器人:Theme.Holo.Light.NoActionBar
和
机器人:Theme.Wallpaper.NoTitleBar
改变它我做
@Override
protected void onNewIntent(final Intent intent) {
super.onNewIntent(intent);
Utils.PrintInfo("MainActivity.onNewIntent");
if (AppSettings.Data.WallpaperThemeChanged) {
AppSettings.Data.WallpaperThemeChanged = false;
startActivity(new Intent(this, ThemeReloadActivity.class));
finish();
return;
}
}
Run Code Online (Sandbox Code Playgroud)
用ThemeReloadActivity
这样的
public class ThemeReloadActivity extends Activity {
@Override
protected void onResume() {
Utils.PrintError("ThemeReloadActivity.onCreate");
Activity activity = MainActivity.getMainActivity();
activity.finish();
startActivity(new Intent(activity, activity.getClass()));
super.onResume();
}
}
Run Code Online (Sandbox Code Playgroud)
这是该活动的Manifest片段
<activity
android:name="com.maxcom.launcher.MainActivity"
android:clearTaskOnLaunch="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
但有时如果我垃圾邮件主页主题没有改变,看起来应用程序根本不会重新启动