How Can I Change Start Page of Android Studio for LibGDX - java

I create a game with LibGDX and I made a main menu for it but I can't do start page this main menu. How Can I do it? Can you help me
enter image description here

You see that
<intent-filter>
<action ...
<action ...
</intent-filter>
part of code? That code controls which one of your activities will be the launching/main activity. Just cut that intent filter and paste it inside of your AndroidLauncher activity tag (which I pressume is your menu).

Related

Inculding a soft keyboard in an application

For a research project, I'm developing an android chat application. For this, it is crucial that all users of the application should use the same, modified keyboard.
My question is the following: Is it possible to deliver a soft keyboard like the simple-keyboard (https://github.com/rkkr/simple-keyboard) with the application? Or alternatively, is it possible to force the user to utilize a certain keyboard for the text input?
Thanks in advance.
It isn't possible to force a keyboard in a non rooted phone, since there's a security block. You can however ask the user to select your keyboard as in Robert's answer:
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
imeManager.showInputMethodPicker();
And yes, you can add it in your application, you just need to add the keyboard code within your app, take a look a this question to see how to make a keyboard. But the most important part probably is the Manifest, because it is what will make your application show in the input method picker:
Code by Suragch:
<manifest ...>
<application ... >
<activity ... >
...
</activity>
<service
android:name=".MyInputMethodService"
android:label="Keyboard Display Name"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod"/>
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="#xml/method"/>
</service>
</application>
</manifest>

Combining Modules Android Application

I'm doing an Android project on Eclipse and I have 2 independent apps sources(Modules). How do I combine these two modules, such that when a button (present on first app) is clicked, the second app is launched?
As far I've just created the button and that's it.Any Help would be appreciated.
As I'm a beginner, please be specific :) Thank you!
In the manifest of the second app :
<activity
android:name=".MainActivitySecondApp"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.external.intentReceiver" />
</intent-filter>
</activity>
And then place the following code inside the onClickListener of the Button in the first App :
Intent intent = new Intent();
intent.setAction("com.external.intentReceiver");
context.startActivity(intent);
So, when the button is clicked, an intent of the type com.external.intentReceiver will be fired. The MainActivitySecondApp will then open since it is meant to handle such intents as defined in the Manifest.

Android - Add buttons to stock camera

I currently have an app that has a Share Via button on images, I was wondering if it's possible to maybe somehow add a button to the camera itself that allow to take a picture and pass it to my activity?
I know I can make an activity which takes an image from within my activity and then get the image, but I was wondering if there's a way to add it to the stock camera.
Thanks
You can only register to the share intent from the gallery:
<intent-filter ...>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
This will allow your users to take pictures, than share to your app from the gallery (not from camera app)
For obvious reasons, you cannot add a button for your app only in stock camera app.

How can I show a specific activity when application enters foreground from background?

I have an application with several activities.One of them is Login activity and this activity defined as MAIN in my app in manifest:
<activity
android:name="com.company.myapp.AuthorizationMainActivity"
android:label="#string/app_name"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The problem when my app enters background (e.g. I press home button) and then I open the app again - the Login page is showed to me. How can I show activity which was active for user at the moment application enter background?
If you don't explicitly want to use it for a special requirement, remove "android:launchMode="singleTask".
A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. (found here at Android Developes)
Use a dummy activity as your base activity that launches and in that activity check to see if you need to display the login activity or another one. Then start that specific activity you want to go to from the dummy activity.
make sure you set the dummy activity to noHistory in the manifest so the user cannot navigate back to it
if(needsLogIn){
Intent i = new Intent(this,LoginActivity.class);
startActivity(i);
}else{
Intent i = new Intent(this,OtherActivity.class);
startActivity(i);
}
Remove android:launchMode="singleTask" > singletask activity will be the root and when you press home button all the activities above it will be removed. when you remove android:launchMode="singleTask" then the default behaviour will take place ie when you press home button and then launch again it will open the activity from where you left. have a look at the link http://developer.android.com/guide/components/tasks-and-back-stack.html

How do I make my custom camera app the default one?

If I would use the following code:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent,1);
it would start the default Android camera app right... I've written a custom camera app, but how do let Android know that it's a camera app, and that the user should be given the choice which Camera app to use.
In other words, if I used the code above, my app should start, and not the default android one.
but how do let Android know that it's a camera app, and that the user should be given the chose which Camera app to use.
Have an <intent-filter> on an <activity> for that action:
<intent-filter>
<action android:name="android.media.action.IMAGE_CAPTURE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
The next time that somebody executes your above startActivityForResult() call, you will appear in the chooser alongside anything else that supports that Intent structure.

Categories