|
are you storing them as DateTime or as string? it's quite difficult to handle dates stored as string, there are a lot of cases that you have to consider. Either store it as DateTime or as byte and convert bytes to datetime. Never save a Date as a string unless you want only to display that value and not do calculations
|
|
|
|
|
I'm looking for a way to implement a simple list view scrolling in my Firebase app, but I am not getting any way out how to implement this. I have already tried 2-3 tutorials and documentation available on the Internet, but didn't the required result.
In my app I want scrolling like at starting first 10 list items load then each time on scrolling next 10 or 20 items will load until the last item appears at the bottom of the list.
So I tried retrieving first 10 items the following way :
<pre>private void readsposts(){
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
reference.keepSynced(true);
reference.child("Posts")
.limitToLast(10)
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
postList.clear();
for(DataSnapshot snapshot:dataSnapshot.getChildren()){
Post post = snapshot.getValue(Post.class);
for(String id:followingList){
if(post.getPublisher()!=null && post.getPublisher().equals(id)){
postList.add(post);
}
}
if(post.getPublisher()!=null && post.getPublisher().equals(firebaseUser.getUid())){
postList.add(post);
}
postAdapter.notifyDataSetChanged();
}
mProgressBar.setVisibility(RecyclerView.GONE);
}
@Override public void onCancelled(DatabaseError databaseError) {
mProgressBar.setVisibility(RecyclerView.GONE);
}
});
}
In the above code, as you can see I am generating Log to check if data is fetched from the firebase, but I got no output Android monitor.
I have no idea how can I implement Firebase Scrolling in my Recycler view. I think this is a common problem for those who implement infinite-scroll in recycler view/ list view.
Could you please help me implementing this feature. Thanks.
|
|
|
|
|
I have a good working code for infinite scroll that gets item from online service(parse server) but it is in xamarin, you want me to post it?
|
|
|
|
|
|
If we're being brutally honest:
I realize that English may not be your first language, but there is quite a bit of cleanup needed in the two paragraphs (e.g., "For instance[comma] the plate in the center has four neighbors"). Individually, not necessarily a big deal, but altogether, it makes for a less-than-professional offering.
What's the former order? How do I know if I'm making progress, or simply further rearranging the "plates?"
All of the screenshots seem pointless. It reminds me of those "find the differences between thee two pictures" activities that we played as kids, except in this case, it's just colored squares.
If the game does not work when the device's orientation changes, then don't allow it. Telling the user to not rotate their device is just wrong, and comes across as amateurish.
Keep going. You'll get there.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 5-Dec-19 9:00am.
|
|
|
|
|
Dont use whats new play store section to write app features, only use it for update changelog
|
|
|
|
|
Hi,
trying to figure out how exceptions propagate and should be handled.
My Visual Studio 2019 test solution consists of:
1. C++Dynamic Library (.so), Target API Level android-27, exceptions enabled with "-fexceptions" flag
2. Android 9.0 (Pie) test application using library above, in OnCreate method exception handling is added as follows:
AndroidEnvironment.UnhandledExceptionRaiser += (sender, e) => ...
TaskScheduler.UnobservedTaskException += (sender, e) => ...
AppDomain.CurrentDomain.UnhandledException += (sender, e) => ...
When I throw exception in the library:
throw 0xBEEF;
Android application ends execution. No exception is caught.
What I can see in the Android Device Monitor is:
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '/usr/local/google/buildbot/src/android/ndk-release-r16/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type int" failed'
So it seems that all exceptions should be handled in the C++ code.
In case of external libraries I can write a wrapper and handle exceptions.
Is this is a right way, or did I miss something?
If this is the right way I am looking for a documentation reference confirming it. Assuming there is any.
My test program can be accessed here
https://github.com/wakeup44/TestSample
wakeup
modified 27-Nov-19 4:54am.
|
|
|
|
|
Hello all.
1- I register a BroadcastReciever in a service dynamically, and then start service. Now if app crashes or I stop service manually, will this also kill the BroadcastReceiver?
2- Same question for ContentObserver. I add ContentObserver for listening changes to addition/updation/deletion of contacts. Will this ContentObserver be also killed if somehow the service is destroyed
Thanks for any input.
|
|
|
|
|
You could probably find the answer by running the code in the debugger and killing the service.
|
|
|
|
|
Since its appearance several years ago, Kotlin has become very popular among Android developers. Google has already announced its official support. According to Stack Overflow Developer Survey 2018, Kotlin is the 2nd most loved language and the fourth most wanted worldwide. So, what do you think about the global migration from Java to Kotlin? Will it be?
|
|
|
|
|
Quote: Do you believe that Kotlin will become more popular than Java? Languages come, languages go. In my—almost 7 wasted years of development with community—experience I have seen languages being introduced, and languages being left to die. When I started learning, people told me to not use Windows Forms as it was dead, guess what? It is still being used and is still available in .NET Core 3.0—a completely revamp of the framework! So it is irrelevant as to what is better or what is not.
Everything has its own place, you cannot do database programming with C#, no matter how much you improve Entity Framework (Core).
Quote: Kotlin has become very popular among Android developers It has, ever wondered why? The reason was that Java lacked so many important features that a programmer might require. There is no operator overloading, generics are only compile-time, static functions are available on instance functions, asynchronous support (although available with community-written module) is very poor, infact bizarre. Moreover, several of the language constructs that could have helped improve developer experience and productivity were never included up until Java 8 and beyond.
Now Java is looking at the lambda features, and is about to introduce the var keyword, which C# and others had a decade ago. Man, a decade ago!
So it is not that Kotlin is gaining popularity, rather Java is becoming a very frustrating language to work with.
Quote: So, what do you think about the global migration from Java to Kotlin? Will it be? It has already happened, read your own post again.
A professional tip that I would want to give you here would be, if you really want to learn something new for Android development, go learn Dart and use Flutter. I have been using several cross-platform tools and runtimes to develop apps, I have used Xamarin (and Xamarin.Forms), React Native, and Flutter. Here is one of the apps that I developed using Flutter, the development experience that I have had so far is almost unparalleled, Afzaal Ahmad Zeeshan / cloud-storage-flutter · GitLab, explore the source code and see how easy it is to create activities, new controls, provide state-management mechanisms, and much more.
I think Flutter has a bright future, and Dart as a language is really interesting language and provides a Java-like syntax, but amazing features as if TypeScript, C#, Java and C++ had a baby...
Flutter - Beautiful native apps in record time
No, not in that way, man. :facepalm:
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I am a newbie here in Android, however, I do know one thing. Whenever you install Android Studio, Kotlin is the "Default" language.
That says, GOOGLE is 100% behind Kotlin.
|
|
|
|
|
|
Kotlin is fancy however regardless of whether I got why and how conclusion and scala have been made, I didn't actually comprehend the motivation behind Kotlin. The Java language is at a generally excellent spot, the additional layer Kotlin gives doesn't appear to be relevant enough
It is fancy, it finishes a few things, yet the business guidelines are better on each end IMHO. I read a contention saying that it is extremely simple doing parallelism in Kotlin since java 8 is additionally very simple getting it done.
|
|
|
|
|
I'm going to attach my .jar file to an already running apk in emulator(BlueStack). I can attach .jar file to running java application on windows. But for running apk in emulator, it is not the same. Any help for me. thanks.
modified 10-Oct-19 12:50pm.
|
|
|
|
|
What do you mean by "attach my .jar file to an already running apk"? How do you plan to attach it?
|
|
|
|
|
Thanks for your reply. I have one apk, but no project of it. At running time of the apk in emulator, I want to hook some functions of apk to get some information, so I'm going to inject my .jar to it. Before I have injected my agent jar file to running java application, but in case of apk I have no idea. Please help me.
|
|
|
|
|
|
There are a lot of android emulators are available that help you run the apk files in the PC. some of them are like bluestacks ,andy,coplayer,AMyDuos.Besides that you can install andriod in vmware and install apps
|
|
|
|
|
Hello there. I am setting a click listener on a relative layout. It works fine. But today I got couple of crashes on this click listener from the user. I set this click listener in the onCreate() function of the activity. Here is what my code looks like
@Override
protected void onCreate(Bundle savedInstanceState) {
layoutHomeButton = findViewById(R.id.layoutHomeButton);
layoutHomeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
And following is the exception I get
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3021)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3156)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1864)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:205)
at android.app.ActivityThread.main (ActivityThread.java:6991)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:884)
Caused by: java.lang.NullPointerException:
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityPlayVideo.onCreate (ActivityPlayVideo.java:210)
at android.app.Activity.performCreate (Activity.java:7159)
at android.app.Activity.performCreate (Activity.java:7150)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3001)
what am I doing wrong? Thanks
|
|
|
|
|
layoutHomeButton = findViewById(R.id.layoutHomeButton);
It may be that the above line failed, so layoutHomeButton is null and causes the exception. Use the debugger to see if that is the case.
|
|
|
|
|
It is never null when I debug. It always finds a resource.
|
|
|
|
|
Then something else must be the problem, but it is impossible to guess what. You need to look at ActivityPlayVideo.java:210 if it is available.
|
|
|
|
|
Then you should be able to add:
layoutHomeButton = findViewById(R.id.layoutHomeButton);
if (layoutHomeButton != null)
layoutHomeButton.setOnClickListener(new View.OnClickListener()...
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hello there. I have this BroadcastReciever which I register and unregister dynamically, in a BASE activity. The purpose, of this receiver, is very simple. I check if HOME button is pressed? The registration of the receiver is as follows:
ActivityBase
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHomeWatcher = new HomeWatcher(this);
mHomeWatcher.setOnHomePressedListener(new OnHomePressedListener() {
@Override
public void onHomePressed() {
}
@Override
public void onHomeLongPressed() {
}
});
mHomeWatcher.startWatch();
}
protected void stopHomeWatcher(){
if(mHomeWatcher != null) {
mHomeWatcher.stopWatch();
mHomeWatcher.setOnHomePressedListener(null);
mHomeWatcher = null;
}
}
HomeWatcher
public class HomeWatcher {
public HomeWatcher(Context context) {
mContext = context;
mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
public void setOnHomePressedListener(OnHomePressedListener listener) {
mListener = listener;
mReceiver = new InnerReceiver();
}
public void startWatch() {
if (mReceiver != null) {
mContext.registerReceiver(mReceiver, mFilter);
}
}
public void stopWatch() {
if (mReceiver != null) {
if(mContext != null)
mContext.unregisterReceiver(mReceiver);
}
}
class InnerReceiver extends BroadcastReceiver {
final String SYSTEM_DIALOG_REASON_KEY = "reason";
final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
if(reason.trim().toLowerCase().equals("homekey")) {
}
}
}
}
}
}
As you can see, I test for various NULLs. Why do I still get this weird IllegalArgumentException ?
java.lang.IllegalArgumentException:
at android.app.LoadedApk.forgetReceiverDispatcher (LoadedApk.java:1012)
at android.app.ContextImpl.unregisterReceiver (ContextImpl.java:1360)
at android.content.ContextWrapper.unregisterReceiver (ContextWrapper.java:608)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.utils.HomeWatcher.stopWatch (HomeWatcher.java:39)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityBase.stopHomeWatcher (ActivityBase.java:442)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityMain.access$301 (ActivityMain.java:77)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityMain$15.onClick (ActivityMain.java:911)
at android.view.View.performClick (View.java:5703)
at android.view.View$PerformClick.run (View.java:22811)
at android.os.Handler.handleCallback (Handler.java:836)
at android.os.Handler.dispatchMessage (Handler.java:103)
at android.os.Looper.loop (Looper.java:203)
at android.app.ActivityThread.main (ActivityThread.java:6297)
|
|
|
|