Is there a possibility in LibGDX to call methods in the "AndroidLauncher" class, have tried quite a lot but it does not go.
I hope someone can give me an answer.
Bye
Hopefully you're trying to call method of AndroidLauncher class which is in android module.
You can do this by interfacing, try this
https://github.com/libgdx/libgdx/wiki/Interfacing-with-platform-specific-code
Related
Android Studio Intermediate here with what I hope is not a redundant question:
I encountered an issue while building a splash screen for the very first time. I'm following the process posted here by David Medenjak, which encourages to use a theme in order to have it be displayed while the app is in the process of booting up:
https://blog.davidmedenjak.com/android/2017/09/02/splash-screens.html
I followed this very closely and am certain everything should be in order.
The very last step for basic functionality, titled "Registering the Splash Screen", suggests building a java file to handle switching to your application once it finishes loading. The java code provided on the blog implements an abstract class called Application.ActivityLifecycleCallbacks, yet the code provided does not implement the obstract methods of this superclass.
I did some research on how to implement this superclass but I'm not familiar with it enough to know how to do so and retain the functionality I need. My java class looks just like the one described in the blog.
Here is another guide on this superclass I found to help with implementing, which implements very few methods:
https://medium.com/#mobile_develop/android-application-development-detecting-when-your-app-enters-the-background-or-foreground-bbced47ad8a5
I apologize if the answer is obvious. My hope is to communicate with David, since he's active on StackOverflow. Maybe #'ing him to this thread would work. Any tips on how to implement the class (if necessary) would be greatly appreciated.
For the abstract methods that are not implemented in the super class, simply implement them as empty method definitions. The Example you can refer to is the following from the blog author's included source.
I was going through vogella's fragment tutorial and I came across this method call in the MyListFragment class:
listener.onRssItemSelected(newTime);
However, this onRssItemSelected method is actually defined(implemented) in the RssfeedActivity class. SO my questions, how did MyListFragment class know to go to the RssfeedActivity class to find the onRssItemSelected method?
Most likely he is implementing a callback to allow the fragments to communicate with each other. The following link explains the process much better than I ever could:
http://developer.android.com/training/basics/fragments/communicating.html
I am working with Android Fragments pretty extensively and one of the problems I am having is the lack of proper mechanism to pass complex objects to it.
In the android developers documentation for Fragments, they have a static method called newInstance called with some simple arguments which will be packaged into a Bundle and used inside the Fragment. However this method cannot be employed for passing complex objects.
Because I have been using the Fragments api a lot, it is becoming more and more important to have complex objects passed to it. One way to do this is by implementing the Parcelable interface, which I don't want to do for all the classes.
So, I thought I could do this :
Define an interface like this in the Fragment:
// Container Activity must implement this interface
public interface ReceiveDataInterface {
public MyClass getData(uniqueFragmentID);
}
Force the Activities using this fragment to implement the interface and call ReceiveDataInterface.getData(getArgument.getString(UNIQUEID))
In the Activity instantiate fragment using the newInstance method by passing a uniqueFragmentID and implement the ReceiveDataInterface which gives data based on uniqueFragmentID.
Is it a good idea to do this? if not, why? and how should I go about doing this?
Note:This is done in the same lines as OnArticleSelectedListener described in the documentation.
Any help is much appreciated.
We use this approach for any app we build for android. It works well. I havent tested every method of doing this, but i think this is among the best way.
Another approach would be to make the Fragment themselves independent. Why not write the code that fetches data from network/database in the Fragment itself?
I need to add some logic to GenericModel by means of extending it, but I understand that Play uses generics to enhance the GenericModel. What would be the right and most convenient way to extend this class?
I tried to do this, but some of the methods in GenericModel simply throw a UnsupportedOperationException exception, so this is clearly enhanced somewhere else.
Check out db.jpa.Model which also extends GenericModel.
If you intend to extends the GenericModel, I would do it in the models package. No need for an external module and it is best to avoid touching playframework core. You will have trouble updating it if you do.
But still, after a quick look at the source code, it seems that you are trying to modify JPA related code. What kind of logic are you talking about?
I've managed to get this working by means of reflection. Everything is now working 100%. :) Not really the best solution, but it works.
Currently in my design I've got a base abstract class that all of my activities extend from, however I discovered recently that in order to use a MapView you need to make your activity extend MapActivity. Since Java does not have multiple inheritance I was wondering if there is any way I can use a MapView without having to recreate my design for my application.
Thanks in advance for any help!
Regards, celestialorb.
Good question. I'm interested in what the others have to say. If the answer is no, you should check out the OSMDroid project; that's the map I'm using for my application. It's nice to have the source code to work with...
The answer is no. It is not possible to utilize a MapView without extending MapActivity. As gulbrandr pointed out there is a similar question here, this may be of use for anyone attempting the same thing that I was.