我有一个像这样的公共方法的片段(F1)
public void asd() {
if (getActivity() == null) {
Log.d("yes","it is null");
}
}
Run Code Online (Sandbox Code Playgroud)
是的,当我调用它(来自Activity)时,它是null ...
FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction();
F1 f1 = new F1();
transaction1.replace(R.id.upperPart, f1);
transaction1.commit();
f1.asd();
Run Code Online (Sandbox Code Playgroud)
它一定是我做错了,但我不知道那是什么
null android android-context android-fragments android-activity
我正在尝试使用Retrofit启用Logging但是我收到此异常:
07-13 12:44:53.278 28698-29248/com.xxxx.debug E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.xxxx.debug, PID: 28698
java.lang.NoSuchMethodError: No virtual method log(Ljava/lang/String;)V in class Lokhttp3/internal/Platform; or its super classes (declaration of 'okhttp3.internal.Platform' appears in /data/data/com.xxxx.debug/files/instant-run/dex/slice-realm-optional-api_16b022358933b490d810e358ea76b13cd4d88163-classes.dex)
at okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:109)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:157)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
at com.xxxx.api.RetrofitClient$1.intercept(RetrofitClient.java:59)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
at okhttp3.RealCall.access$100(RealCall.java:30)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Run Code Online (Sandbox Code Playgroud)
这就是我这样做的方式:
public class RetrofitClient {
private static MyService instance;
public static MyService getInstance(Context context) {
if (instance == null) {
instance = newInstance(context);
}
return …
Run Code Online (Sandbox Code Playgroud) 我正试图从我的设备上获取已安装应用程序的APK.我正在按照这个答案中的说明进行操作,但在拉出它时,adb说APK不存在.这是确切的步骤:
$ adb shell pm list packages
...
(whole list of packages)
...
$ adb shell pm path com.google.android.apps.books
package:/data/app/com.google.android.apps.books-1/base.apk
$ adb pull /data/app/com.google.android.apps.books-1/base.apk
adb: error: remote object '/data/app/com.google.android.apps.books-1/base.apk' does not exist
Run Code Online (Sandbox Code Playgroud)
如何将此文件提取到本地驱动器?
我想使用valid-url来验证使用JSFiddle的一些URL,以便我以后可以共享它.我尝试index.js
从Github(https://raw.githubusercontent.com/ogt/valid-url/master/index.js)添加该文件的链接,但是Fiddle说:
Github不是CDN,因此使用它会导致加载文件时出现问题.你还有吗?
显然当我尝试使用它时,会抛出一个错误:
拒绝从[...]执行脚本,因为它的MIME类型('text/plain')不可执行,并且启用了严格的MIME类型检查.
那么,有没有办法在JSFiddle中使用npm包?或者任何解决方法来实现这一目标?
我们正在同一组织下开发几个NPM软件包:
@aerogearservices/core
@aerogearservices/core-rn
@aerogearservices/core-cordova
Run Code Online (Sandbox Code Playgroud)
core-cordova
通过依赖关系安装的Cordova插件在哪里(有关范围包的更多信息,请阅读)。
相关文件:
应用程序的package.json
{
...
"dependencies": {
"@aerogearservices/core-cordova": "1.0.0",
...
},
"cordova": {
"plugins": {},
"platforms": ["ios", "android"]
}
}
Run Code Online (Sandbox Code Playgroud)
插件的package.json
{
"name": "@aerogearservices/core-cordova",
"version": "1.0.0",
...
"cordova": {
"id": "aerogearservices-core-cordova",
"platforms": [
"android"
]
},
"dependencies": {
"@aerogearservices/core": "1.0.0"
},
"engines": {
"cordovaDependencies": {
...
}
}
}
Run Code Online (Sandbox Code Playgroud)
插件的plugin.xml
... ... Apache 2.0
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
...
</config-file>
<source-file
...
/>
</platform>
Run Code Online (Sandbox Code Playgroud)
该插件还没有执行任何操作,我只是尝试将其安装在我的应用程序中,但是在运行时出现cordova platform add android
此错误:
UnhandledPromiseRejectionWarning: CordovaError: …
Run Code Online (Sandbox Code Playgroud) 我的项目中有 3 个模块:common
,admin
和client
.
第一个是带有抽象的 Android 库,LoginActivity
其他模块(应用程序)从中扩展。
LoginActivity
有自己的布局和实现的所有方法,但只有一个:tryLogin(user, password)
导航到主要活动,每个应用程序都不同。
我遵循了官方文档,但是当我单击signIn
按钮时,不会调用 OnClickListener。此外,所有绑定视图都为空...
这是所有相关代码admin
(两个模块几乎相同)
项目级 build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath "io.realm:realm-gradle-plugin:1.1.1"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.2.1'
classpath 'io.fabric.tools:gradle:1.21.7'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
常用库 build.gradle
apply plugin: 'com.android.library' …
Run Code Online (Sandbox Code Playgroud) 我最近在Android 4.2设备Spinner
中通过以下getView()
方法膨胀项目时遇到了这个奇怪的错误ArrayAdapter
:
07-27 10:44:18.120 23988-23988/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: xxx.xxx.xxx, PID: 23988
android.view.InflateException: Binary XML file line #21: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.view.View.inflate(View.java:17832)
at xxx.xxx.xxx.adapters.SpinnerAdapter.getView(SpinnerAdapter.java:37)
at android.widget.AbsListView.obtainView(AbsListView.java:2338)
at android.widget.ListPopupWindow$DropDownListView.obtainView(ListPopupWindow.java:1605)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1273)
at android.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1176)
at android.widget.ListPopupWindow.show(ListPopupWindow.java:554)
at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1106)
at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:980)
at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:962)
at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Caused …
Run Code Online (Sandbox Code Playgroud) android ×4
npm ×2
adb ×1
butterknife ×1
cordova ×1
javascript ×1
jsfiddle ×1
null ×1
retrofit2 ×1