我正在尝试在Firebase中创建一个动态链接,当我选择Android应用程序时,它显示错误"将SHA-1添加到此Android应用程序",我已经添加了凭据,但我不是确定我如何"将SHA-1添加到应用程序"
这是怎么做到的?
我已经查看了其他问题,博客和文档,似乎无法找到满足我需求的正确答案.我有两个活动,A和B.当我启动活动B(来自A)时,我希望它立即打开,然后在显示进度条时加载所有内容,而不是仅在加载内容时打开活动,使其成为可能好像它冻结了两秒钟.例如Youtube应用程序或Play商店.
这就是我得到的:
Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent goB = new intent(ActivityA.this, ActivityB.class);
startActivity(goB);
}
});
Run Code Online (Sandbox Code Playgroud)
这是我正在加载的活动:
public class ActivityB extends AppCompatActivity implements OnDateSelectedListener, OnMonthChangedListener {
private static final DateFormat FORMATTER = SimpleDateFormat.getDateInstance();
@Bind(R.id.calendarView) MaterialCalendarView widget;
@Bind(R.id.textView) TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_c_calendar);
ButterKnife.bind(this);
widget.setOnDateChangedListener(this);
widget.setOnMonthChangedListener(this);
textView.setText(getSelectedDatesString());
}
@Override
public void onDateSelected(@NonNull MaterialCalendarView widget, @Nullable CalendarDay date, boolean selected) {
textView.setText(getSelectedDatesString());
}
private String getSelectedDatesString() {
CalendarDay date = widget.getSelectedDate();
if (date …
Run Code Online (Sandbox Code Playgroud) 错误
org.gradle.execution.MultipleBuildFailures:构建完成,失败 1 次。引起:org.gradle.api.tasks.TaskExecutionException:任务':app:compileDebugJavaWithJavac'的执行失败。引起:java.lang.NoClassDefFoundError:javax/xml/bind/JAXBException
当我启用 dataBinding 并尝试在 IntelliJ IDEA 上构建、使用gradlew build
作品构建以及在 Android Studio 上构建时,我收到此错误。
版本
摇篮版本:5.1.1
想法:2019.1.3
Android 插件:(6 月 18 日最新)
爪哇:8
要复现,在Android Studio上创建一个项目,启用dataBinding,在IDEA上打开并尝试构建。
有谁知道为什么会发生这些冲突?
我该如何以android:background="?android:attr/selectableItemBackground""
编程方式完成?
我试过了mView.setBackgroundResource(android.R.attr.selectableItemBackground);
,但没用.
我有一个'添加'按钮和一个带有6个插槽的GridLayout,当我点击'添加'按钮时,view1被添加到gridlayout中,我再次点击'添加'按钮,添加了view2,依此类推.
if (!theLayout1.isShown()) {
Grid.addView(theLayout1);
} else if (!theLayout2.isShown()) {
Grid.addView(theLayout2);
} else if (!theLayout3.isShown() ) {
Grid.addView(theLayout3);
} ..... // this goes on
Run Code Online (Sandbox Code Playgroud)
添加视图后,检查其文本是否已添加到sharedPrefs中,以便在重新创建活动时自动添加它们
if (prefs.getString("text4", null) != null) {
Grid.addView(theLayout4);
}
if (prefs.getString("text5", null) != null) {
Grid.addView(theLayout5);
}
// each view has one EditText
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果我删除view1然后再添加它,它将被放置在我想要的最后一个插槽中,但是当我重新创建活动时它将返回到第一位,因为代码被读取在其中订购它将按初始顺序添加视图.
我希望在完成活动之前按顺序重新创建活动时添加视图,这可能有一个简单的逻辑解决方案,或者我只是非常错误地处理问题,无论如何,需要帮助!
粘性是指不会因调用启动器意图(intent.addCategory(Intent.CATEGORY_HOME
)而关闭的窗口。
以前是通过完成此操作的WindowManager.LayoutParams.TYPE_PHONE
,但是现在不建议使用此类型,并且会在api 28上引发异常:
WindowManager $ BadTokenException ...窗口类型2002的权限被拒绝
由于Facebook的Messenger在其聊天窗口“ Heads”中进行了这种行为,因此仍然可能会发生这种行为,这是基于这样的假设:由于Facebook已预先安装在许多rom上,因此没有获得系统应用程序许可。
使用WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
不起作用(即,按下主页按钮也会隐藏覆盖窗口)。
编辑:问题是当用户单击主屏幕按钮/调用启动器意图时,如何具有不被删除的覆盖窗口。并非如此TYPE_APPLICATION_OVERLAY
,这是事实,TYPE_PHONE
但已过时。
编辑2:显然,这确实对某些人有用,这是我正在运行的代码:
class MyClass {
var params: WindowManager.LayoutParams = WindowManager.LayoutParams(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
else WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT
).apply {
windowAnimations = android.R.style.Animation_Dialog
gravity = Gravity.CENTER or Gravity.CENTER
x = 0
y = 0
}
var windowManager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
init {
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
rootView = layoutInflater.inflate(R.layout.view_overlay, null)
windowManager.addView(rootView, params)
} …
Run Code Online (Sandbox Code Playgroud) 我有一个RecyclerView,当我点击第一个视图时它会添加另一个视图,就像在图像中一样,我想要的是设置"添加"视图,其中ID为"1",以便在回收器的最后位置固定而不是首先.
我的适配器:
public class AddEventsAdapter extends RecyclerView.Adapter<AddEventsAdapter.ViewHolder> {
private List<String> items = new ArrayList<>();
public void addItem(String name) {
items.add(name);
notifyItemInserted(items.size() - 1);
}
public void removeItem(int position) {
items.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, items.size());
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View view = inflater.inflate(R.layout.add_event_item, parent, false);
return new ViewHolder(view);
}
@Override
public int getItemCount() {
return items.size();
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.setEventNameName(i + "");
if(position == 0)
{
holder.theLayout.setBackgroundColor(Color.parseColor("#7F9099")); …
Run Code Online (Sandbox Code Playgroud) 我知道,当用户更新他的应用程序时,数据(如在sharedprefs文件中)不会被删除,但是预定的广播呢?PendingIntent会被取消吗?
因此,我只是将compileSdkVersion更新为26,并且似乎找不到在编译时导致此问题的原因:
原因:java.io.IOException:无法生成v1签名
...
原因:java.lang.IllegalArgumentException:缺少必需的Manifest-Version属性
我唯一尝试过的是将版本代码添加到清单中,而不是gradle文件中,但是似乎没有任何影响。
这是我的gradle构建文件的一部分
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "xxx.xxx.com"
minSdkVersion 14
targetSdkVersion 25
versionCode xxx
versionName "x.x.x"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/*'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
Run Code Online (Sandbox Code Playgroud)
以及整个堆栈跟踪:
[10:58:50] john @ bob:project $ gradle assembleDebug --stacktrace
配置项目:app已弃用项目':app'中的配置'compile'。请改用“实现”。项目':app'中的配置'androidTestCompile'已弃用。使用“ androidTestImplementation”代替。项目':app'中的配置'testCompile'已弃用。使用“ testImplementation”代替。CompileOptions.bootClasspath属性已被弃用,并计划在Gradle 5.0中删除。请改用CompileOptions.bootstrapClasspath属性。在org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(CompileOptions.java:273)在org.gradle.api.tasks.compile.CompileOptions_Decorated.setBootClasspath(来源不明)在com.android.build.gradle.tasks。厂。
任务:app:processDebugGoogleServices解析json文件:/.../project/app/google-services.json
失败:构建失败,发生异常。
出了什么问题:任务':app:packageDebug'的执行失败。
无法生成v1签名
尝试:使用--info或--debug选项运行,以获取更多日志输出。与--scan一起运行以获取完整的见解。
异常是:org.gradle.api.tasks.TaskExecutionException:任务':app:packageDebug'的执行失败。在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)在org.gradle org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)上的.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter的.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)。
在https://help.gradle.org上获得更多帮助
2秒内失败,可执行26项任务:执行4项,更新22项