Apple有关于如何更改IOS应用程序的显示名称的明确说明,但它们对于react-native应用程序没有用,因为文件夹结构不同.如果您有一个react-native应用程序,如何更改显示名称?
今天,回顾我的旧代码,我发现OnCameraChangeListener()现已弃用.
我发现很难理解如何修复我的这段代码:
mGoogleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
// Cleaning all the markers.
if (mGoogleMap != null) {
mGoogleMap.clear();
}
mPosition = cameraPosition.target;
mZoom = cameraPosition.zoom;
if (mTimerIsRunning) {
mDragTimer.cancel();
}
mDragTimer.start();
mTimerIsRunning = true;
}
});
Run Code Online (Sandbox Code Playgroud)
新的侦听器(又名OnCameraMoveListener())方法onCameraMove()没有CameraPosition cameraPosition输入变量,所以我很丢失:有没有办法回收我的旧代码?
这里有一些参考.
我正在尝试创建我的应用程序组件,但Dagger不会生成我的应用程序组件.这是MyApplication类
class MyApplication : Application() {
companion object {
@JvmStatic lateinit var graph: ApplicationComponent
}
@Inject
lateinit var locationManager : LocationManager
override fun onCreate() {
super.onCreate()
graph = DaggerApplicationComponent.builder().appModule(AppModule(this)).build()
graph.inject(this)
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的AppComponent类
@Singleton
@Component(modules = arrayOf(AppModule::class))
interface ApplicationComponent {
fun inject(application: MyApplication)
}
Run Code Online (Sandbox Code Playgroud)
这是我在github上的项目
这是错误日志
Error:(7, 48) Unresolved reference: DaggerApplicationComponent
Error:(28, 17) Unresolved reference: DaggerApplicationComponent
Error:Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
Information:BUILD FAILED
Information:Total time: …Run Code Online (Sandbox Code Playgroud) 我收到了这个错误.当我尝试使用Facebook登录我的应用程序时.当我第一次进行身份验证时,它将正常工作.在我取消了我的应用程序并且现在尝试使用Facebook登录后,我收到此错误.
另一个问题:在device1中进行身份验证并尝试在设备2上使用facebook登录时也会出现同样的错误.
解决方案我发现:当我从Facebook应用程序设置中删除应用程序身份验证时,它正在上面的场景中运行,但这不是一个很好的解决方案,我们可以告诉用户如何执行此操作?
btnFbLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(accessToken != null) {
boolean expires = accessToken.isExpired();
if(!expires) {
performFbLoginOrSignUp(accessToken);
}
} else {
LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
callbackManager = CallbackManager.Factory.create();
if (loginButton != null) {
loginButton.setReadPermissions("public_profile", "email", "user_friends");
if (CommonUtil.isConnectingToInternet(LoginActivity.this)) {
loginButton.performClick();
loginButton.setPressed(true);
loginButton.invalidate();
loginButton.registerCallback(callbackManager, mCallBack);
loginButton.setPressed(false);
loginButton.invalidate();
}
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
在Facebook的例子中也有一个问题: Facebook示例的GitHub链接
重现的步骤:
启动应用程序使用Facebook登录验证FB配置文件.
取消安装该应用并重新安装.
现在尝试使用Facebook登录.
我试图向服务器POST请求获取数据,但有时它发生了SocketTimeoutException!
我曾经Ok3Client解决它,但我面临同样的例外如何解决它?
我的代码如下
public void getNormalLogin() {
if (mProgressDialog == null) {
mProgressDialog = ViewUtils.createProgressDialog(mActivity);
mProgressDialog.show();
} else {
mProgressDialog.show();
}
if (Build.VERSION.SDK != null && Build.VERSION.SDK_INT > 13) {
restadapter = new RestAdapter.Builder().setEndpoint(HOST).setLogLevel(RestAdapter.LogLevel.FULL).setClient(new Ok3Client(new OkHttpClient())).build();
mApi = restadapter.create(Api.class);
mApi.SignIn(etEmail.getText().toString(), etPassword.getText().toString(), new Callback<ArrayList<SignUpMainBean>>() {
@Override
public void success(ArrayList<SignUpMainBean> signUpMainBeen, Response response) {
mProgressDialog.dismiss();
LOGD("Status:: ::", String.valueOf(response.getStatus()));
LOGD("Code:: ::", String.valueOf(signUpMainBeen.get(0).getCode()));
if (signUpMainBeen != null && signUpMainBeen.size() > 0) {
if (signUpMainBeen.get(0).getCode() == 1) {
for …Run Code Online (Sandbox Code Playgroud) 我的团队和我开发了Android应用程序,并决定了所有应遵循的编码指南.因此,我开始按照以下链接实现自定义lint规则:
我遇到的问题实际上是在项目的基础上实现这些lint规则.当我跑步时./gradlew clean build test install,按照规定适用规则,一切都很顺利.但是当我用./gradlew aarWrapper:assemble它构建aar库并将其添加到我的libs文件夹时,linting不起作用.
我将以下内容添加到我的build.gradle文件中以添加库
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'aarWrapper-debug', ext: 'aar')
}
Run Code Online (Sandbox Code Playgroud)
我不确定我错过了什么,但是当我运行./gradlew lint它时,运行linter而不是我的自定义规则......非常感谢任何帮助,提示或建议.
编辑1
这是运行gradle时的终端输出.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareAarWrapperDebugLibrary UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2421Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidVolleyVolley100Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidAnswers138Library …Run Code Online (Sandbox Code Playgroud) 我们必须enterPictureInPictureMode()将活动从其当前形式转移到画中画表示.
除了破坏活动之外,我们还原的方法是什么,将活动恢复到正常状态?没有exitPictureInPictureMode(),leavePictureInPictureMode()或janeGetMeOffThisCrazyPictureInPictureModeThing()方法Activity,文档似乎没有涵盖替代方案.
我对Android O的解决方案感兴趣,对于移动设备上的画中画模式,虽然如果它也适用于Android TV,太棒了!
更新2017-04-08:如果您想要的是当用户单击X按钮退出画中画模式时返回正常模式,您可以执行以下操作:
@Override
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode);
if (!isInPictureInPictureMode) {
getApplication().startActivity(new Intent(this, getClass())
.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
}
}
Run Code Online (Sandbox Code Playgroud)
关键位是调用startActivity()再次启动当前活动FLAG_ACTIVITY_REORDER_TO_FRONT.对于singleTask活动,您需要在某些非Activity上下文中调用它,例如Application单例.这似乎没有触发onStop()或onStart(),但它确实触发onNewIntent()(无论Intent你传递给什么startActivity()).
我使用ConstraintLayout制作一些简单的应用程序进行测试.但我有一些问题.
这是我的代码
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.user.myapplication.activity.MainActivity">
<Button
android:id="@+id/btn_launch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="16dp"
android:text="launch"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/text_view"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:text="Hello World!"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_launch" />
<include
layout="@layout/content_main"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_view" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="123456"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="98765"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" …Run Code Online (Sandbox Code Playgroud) 在我的模块中,在我的基础Application类中
component = DaggerCompClassComponent.builder()
.classModule(new ModuleClass()).build();
Run Code Online (Sandbox Code Playgroud)
它找不到DaggerCompClassComponent.
我有模块build.gradle
apply plugin: 'com.neenbedankt.android-apt'
.........................
apt 'com.google.dagger:dagger-compiler:2.8'
compile 'com.google.dagger:dagger:2.8'
provided 'javax.annotation:jsr250-api:1.0'
Run Code Online (Sandbox Code Playgroud)
在Project build.gradle中,
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Run Code Online (Sandbox Code Playgroud)
我已经完成了build/rebuild/clean/restart项目.我有一个Component类,我在其中注入对象和一个ModuleClass,我提供了要注入的对象.
不生成Dagger组件的原因是什么.上课?
编辑:
这是我的ModuleClass,用@Module注释:
@Provides
@Singleton
public Interceptor provideInterceptor() {
return new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request.Builder builder = chain.request().newBuilder();
builder.addHeader("AppName-Android", BuildConfig.VERSION_NAME + "-" + BuildConfig.VERSION_CODE)
.addHeader("Content-Type", "application/json");
return chain.proceed(builder.build());
}
};
}
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Interceptor interceptor) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.interceptors().add(interceptor);
return builder.build();
}
@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient …Run Code Online (Sandbox Code Playgroud) 我正在Kotlin从官方文档中学习,我在class下面创建了一个我创建了一个constructor有两个的文档parameters.身体constructor在init块中.
class Person(name: String, surname: String) {
init {
Log.d("App", "Hello");
}
}
Run Code Online (Sandbox Code Playgroud)
好吧,我想创建一个更constructor将采取一个parameter在constructor.是做什么的Kotlin