草庐IT

context-switch

全部标签

android - Material 设计 : Add circular reveal animation while switching between toolbars

我正在阅读Material设计指南(https://material.io/guidelines/patterns/selection.html)中的“选择”部分,我想在我的应用程序中添加一个效果是在应用程序栏和ActionMode之间切换时的圆形显示动画?另一个工具栏?这是指南中的示例:https://storage.googleapis.com/material-design/publish/material_v_10/assets/0Bwp7jtSjaW36RGF3eUFsRkdqU1U/patterns_selection_item_controlling_desktop_cl

java - "Make sure to call FirebaseApp.initializeApp(Context) first."如何解决这个错误?

所以我正在尝试使用AndroidStudio创建一个简单的android应用程序,当我构建时它看起来很好但是当我运行应用程序时崩溃所以我被告知检查Logcat并且它说FirebaseApp未初始化在我的主要Activity中。所以我添加了FirebaseApp.initializeApp(this);到onCreate()并且它无法解析符号FirebaseApp那么我该怎么做才能解决这个问题?这是我的Github:https://github.com/radekkrowicki/Cv4还有我的主要Activity:importandroid.content.Intent;importa

java - 内部错误 : Bad sparse switch magic - what that means?

今天我得到一个堆栈跟踪,其中有一个非常奇怪的错误。实际上,我可能是第一个得到这个的人(耶!),因为在发布这个问题之前,谷歌中唯一出现的“Badsparseswitchmagic”是在Android源代码中。这是堆栈跟踪的一部分(Android2.3.4):java.lang.InternalError:badsparseswitchmagicatorg.my.app.MyItemAdapter.(MyItemAdapter.java:64)atorg.my.app.MyActivity.onCreate(MyActivity.java:78)从MyItemAdapter构造函数退出时抛

java - 蓝牙 GATT 尝试在空对象引用上调用虚拟方法 'void android.content.Context.sendBroadcast(android.content.Intent)'

我正在编写我的第一个Android应用程序,但没有成功-我在蓝牙GATT的读写可靠性方面遇到了很大的问题。30分钟前,我能够从手机向外围设备写入一个字节,并看到它已收到。我现在不可以。我开始认为这种间歇性错误是导致问题的原因:java.lang.NullPointerException:Attempttoinvokevirtualmethod'voidandroid.content.Context.sendBroadcast(android.content.Intent)'onanullobjectreferenceatandroid.content.ContextWrapper.se

C 语言中的 switch 语句和 while 循环详解

C语言中的switch语句替代多重if..else语句,可以使用switch语句。switch语句用于选择多个代码块中的一个来执行switch(表达式){casex://代码块break;casey://代码块break;default://代码块工作原理switch表达式只会被计算一次表达式的值与每个case的值进行比较如果找到匹配,则执行相应的代码块break语句用于跳出switch块并停止执行default语句是可选的,如果找不到匹配的case,则执行它指定的代码下面的示例使用星期几的数字来计算星期几的名称:intday=4;switch(day){case1:printf("星期一")

android - java.lang.IllegalArgumentException : Invalid context argument error when logout 异常

我创建了一个使用facebook登录和注销的简单应用程序。登录时没问题,但注销时应用程序已停止。有什么解决办法吗?这是我的代码ActivitypublicclassLoginextendsActivityimplementsOnClickListener{ImageViewpic,button;Facebookfb;SharedPreferencessp;TextViewwelcome;@SuppressWarnings("deprecation")@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(

java - 将 Context 作为参数传递给静态辅助方法可能会导致内存泄漏吗?

我有一个由各种静态方法组成的辅助类,其中一个方法需要Context才能访问某些信息。将Context作为参数传递给静态辅助方法可能会导致内存泄漏吗?publicclassConnectionHelper{publicstaticbooleanisConnected(Contextcontext){ConnectivityManagercm=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);returncm!=null;}}静态方法的行为如何,它会在执行后处理上下文引用还是会在内存中停留

java - 基本安卓 : syntax for switch statement instead of else-if

我正在编写一个Android初学者教程,它是一个小费计算器。它运行正常,但我想知道如何用switch语句替换else-if语句。并不是说它对于这个程序的目的来说那么重要,但我只是想围绕语法来思考。packagecom.android.tipcalc;importandroid.app.Activity;importandroid.os.Bundle;importandroid.widget.EditText;importandroid.widget.RadioGroup;importandroid.widget.TextView;importandroid.widget.Button;

java - Android:调用 Context.startService() 后未启动嵌套 Intent 服务

我的嵌套Intent服务定义如下:packagecom.my.package;...//BunchofimportspublicclassMyNotifier...//BunchofvariablespublicclassMissedCallIntentServiceextendsIntentService{privatestaticfinalStringTAG="MissedCallIntentService";publicMissedCallIntentService(){super("MissedCallIntentService");Log.i(TAG,"Creatingint

java - 传入 BroadcastReceiver 的 onReceive() 的 Context 是什么?

传递给BroadcastReciver的onReceive方法的上下文是什么:publicvoidonReceive(Contextcontext,Intentintent)根据officialdocumentation:TheContextinwhichthereceiverisrunning. 最佳答案 一些研究给出了以下结果......对于静态接收器publicclassMyReceiverextendsBroadcastReceiver{@OverridepublicvoidonReceive(Contextcontext,