我开始使用Firebase云消息传递.
我只有指南的示例代码来使用通知和分析.如果我不安装Google Analytics通知工作正常,但当我添加gradle时,我尝试发送通知时遇到此错误:
java.lang.NoSuchMethodError:没有静态方法zzUr()Landroid/content/Intent; 在类Lcom/google/firebase/iid/FirebaseInstanceIdInternalReceiver; 或它的超类(的"com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"声明出现在/data/app/com.myapp.newapp-2/base.apk)在com.google.firebase.messaging.FirebaseMessagingService.zzz(来源不明)在com.google.firebase.iid.zzb.onStartCommand(来源不明)在android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3316)在android.app.ActivityThread.access $ 2200(ActivityThread.java:177)在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1547)在android.os.Handler.dispatchMessage(Handler.java:102)在android.os.Looper.loop(Looper.java:145)的机器人. app.ActivityThread.main(ActivityThread.java:5951)在java.lang.reflect.Method.invoke(本机方法)在java.lang.reflect.Method.invoke(Method.java:372)在com.android.internal. os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1400)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
我在gradle中:
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.google.firebase:firebase-core:9.2.0'
Run Code Online (Sandbox Code Playgroud)
我的MyFirebaseMessagingService:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
Log.d(TAG, "From: …
Run Code Online (Sandbox Code Playgroud) android firebase firebase-cloud-messaging firebase-analytics
我有一行在开头对齐文本,在结尾对齐图像。当我按下图像时,我会显示一个下拉菜单,但它出现在行的开头,我希望它出现在行的末尾。
我尝试在 Modifier 组件中使用 Alignment.centerEnd 但不起作用。
我怎样才能让弹出窗口出现在行的末尾?
@Composable
fun DropdownDemo(currentItem: CartListItems) {
var expanded by remember { mutableStateOf(false) }
Box(modifier = Modifier
.fillMaxWidth()) {
Text(modifier = Modifier.align(Alignment.TopStart),
text = currentItem.type,
color = colorResource(id = R.color.app_grey_dark),
fontSize = 12.sp)
Image(painter = painterResource(R.drawable.three_dots),
contentDescription = "more options button",
Modifier
.padding(top = 5.dp, bottom = 5.dp, start = 5.dp)
.align(Alignment.CenterEnd)
.width(24.dp)
.height(6.75.dp)
.clickable(indication = null,
interactionSource = remember { MutableInteractionSource() },
onClick = {
expanded = true
}))
DropdownMenu(
expanded = expanded,
onDismissRequest …
Run Code Online (Sandbox Code Playgroud) 我是jetpack compose的新手,我正在尝试做一件我无法实现的简单事情。
\n我想要做的是在同一行中对齐一个组件(在本例中是一个表面),位于行的开头,另一个组件(列)位于行的末尾。
\n怎么才能得到这个呢?
\n我正在尝试这个,但它不起作用:
\nRow(Modifier.padding(top = 24.dp)\n .fillMaxWidth()) {\n Surface(\n modifier = Modifier.size(70.dp),\n shape = RectangleShape,\n color = MaterialTheme.colors.onSurface.copy(alpha = 0.2f)\n ) {\n // Image goes here\n }\n\n Column(modifier = Modifier.size(70.dp)) {\n Text("Total",\n fontSize = 12.sp,\n color = AppGreyDark,\n modifier = Modifier.padding(end = 16.dp))\n\n Text("12,99 \xe2\x82\xac",\n fontSize = 18.sp,\n color = AppBlackDark,\n modifier = Modifier.padding(top = 4.dp))\n }\n }\n
Run Code Online (Sandbox Code Playgroud)\n android android-jetpack-compose composable android-compose-layout
突然,我收到了Google Ads的错误消息。我在此找不到任何错误。
请注意,广告展示正确
Google Mobile Ads SDK initialization functionality unavailable for this session. Ad requests can be made at any time.
Run Code Online (Sandbox Code Playgroud) 我已经SMS Retriever API
在谷歌教程和我的调试Build Variant工作中实现了类似的工作.我可以读取短信并获取用户可以登录的代码.
我的问题是,当我在发布版本Variant中运行应用程序sms它不起作用.我收到了短信,但我无法读取代码进行登录.
我在发布模式下更改了AppSignatureHelper生成的哈希,该模式与调试模式不同.在调试工作和发布没有.
一些帮助将是欣赏
代码:
表现:
<receiver android:name=".app.receivers.SmsReceiver">
<intent-filter>
<action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
在我的类中:(在发布和调试模式下,代码将抛出onSucess方法)此方法在onCreate中调用.
private void startSMSListening(){
SmsRetrieverClient client = SmsRetriever.getClient(this);
Task<Void> task = client.startSmsRetriever();
task.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// Successfully started retriever, expect broadcast intent
Log.e("startSMSListening", "listening sms");
sendCode();
showHideLoadingView(false);
}
});
task.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Failed to start retriever, inspect Exception for more details
Log.e("startSMSListening", "failure listening …
Run Code Online (Sandbox Code Playgroud) android android-intent android-broadcast android-broadcastreceiver android-sms
我在 Android 应用程序中使用 Realms 作为数据库。工作正常,但我在我的用户模型中添加了一个新标签,但出现了我需要迁移架构的错误:
java.lang.RuntimeException: Unable to create application com.apelucy.apelucy.app.base.MyApplication: io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors:
- Property 'User.testRealm' has been added.
Run Code Online (Sandbox Code Playgroud)
我该如何进行迁移?我在这里找到了其他解决方案,但我无法在我的代码中实现它们。我无法使用删除和安装应用程序的解决方案。我现在正在开发中,但我需要在生产中更新应用程序。
我的 UserRespository 类:
public class UserRepository {
private static UserRepository sInstance = null;
private Context mContext = null;
public static UserRepository getInstance(Context context) {
if (sInstance == null) {
sInstance = new UserRepository();
sInstance.mContext = context;
}
return sInstance;
}
// DATABASE Methods
public void storeUser(final User user) {
AppSingleton.getInstance().setUser(user);
Realm realm = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 firebase 中进行分页。我遵循了这种方法(Firebase 分页 limitToFirst() 与 limitToLast()),但我无法从firebase获得正确的分页项目,始终获得相同的 3 个项目。
这是下面代码的问题:
我的 firebase 数据库中有 12 个项目。我检索了第一个加载项目的 3 个元素,当我尝试加载更多项目时,我总是得到与第一次加载相同的元素。
我试过: postList.size()-1).getTimestamp().toString()
和 postList.size()-3).getTimestamp().toString() 但总是得到相同的数据
private ArrayList<Post> postList = new ArrayList<>();
private Query allPostsQuery;
private final static int PAGESIZE = 3;
Run Code Online (Sandbox Code Playgroud)
//启动时首先加载项目
linearLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(linearLayoutManager);
mAdapter = new WallAdapter(postList, getFragmentManager(), getActivity(), navigation, mListener, WallFragmentOwn.this);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if(dy > 0) {
visibleItemCount = linearLayoutManager.getChildCount();
totalItemCount = …
Run Code Online (Sandbox Code Playgroud) 每次我构建应用程序时,都会遇到此错误。我认为我已经更新了所有库,有人可以告诉我问题出在哪里?显然,我认为这可能来自Google Play服务,但是我拥有所用所有库的最新版本。
我找不到能解决问题的任何东西
警告:API'variant.getMergeResources()'已过时,已被'variant.getMergeResourcesProvider()'取代。它将于2019年底删除。有关更多信息,请参见https://d.android.com/r/tools/task-configuration-avoidance。要确定正在调用variant.getMergeResources()的内容,请在命令行上使用-Pandroid.debug.obsoleteApi = true来显示更多信息。受影响的模块:应用
首先,我正在尝试很多我在这里找到的例子,但任何事都适合我.
目前,我只能更改动作模式的颜色背景,但不能更改文本颜色和图标的颜色以便返回
一些帮助将不胜感激!
这就是我正在尝试的:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeStyle">@style/Style.ActionMode</item>
</style>
<!-- *************************** Custom ActionMode Bar **************************************-->
<style name="Style.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
<item name="background">@color/color_action_mode_bg</item>
<item name="android:backgroundSplit">?android:attr/actionModeSplitBackground</item>
<item name="android:height">?android:attr/actionBarSize</item>
<item name="android:titleTextStyle">@style/Stl.TitleTextStyle</item>
</style>
<style name="Stl.TitleTextStyle" parent="@style/Widget.AppCompat.ActionMode">
<item name="android:textColor">@color/colorPrimary</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Koin 进行一些测试,但是我收到了“未解析的参考:KoinTest”但是,似乎正在正确执行导入,因为我看不到代码中的任何错误。仅在我尝试时运行测试。
我尝试清理并重建项目并重新启动 android studio,但问题仍然存在
测试班
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.koin.core.context.startKoin
import org.koin.core.context.stopKoin
import org.koin.test.KoinTest
import salva.perez.cabify.di.applicationModule
import org.koin.test.inject
class VoucherPresenterTest : KoinTest {
private val presenter: VoucherContract.Presenter by inject()
@Before
fun before() {
startKoin {
modules(applicationModule)
}
}
@After
fun after() {
stopKoin()
}
@Test
fun testInitViewCorrectly() {
...
}
}
Run Code Online (Sandbox Code Playgroud)
摇篮
implementation 'org.koin:koin-android:2.0.1'
testImplementation 'org.koin:koin-test:2.0.1'
Run Code Online (Sandbox Code Playgroud) android ×10
composable ×2
firebase ×2
ads ×1
android-sms ×1
gradle ×1
koin ×1
kotlin ×1
pagination ×1
realm ×1