Custom Keyboard Java - Potential InputMethod problem - java

One problem I had was that I created a keyboard that even went as far as being successfully installed on my phone while in debugging, yet when I tried to select this specific keyboard, the app stopped working. I think it's something to do with InputMethod and the AndroidManifest, but I'm not completely sure.
There is one yellow warning that tells me that MyInputMethodService has not been included in the AndroidManifest, yet when I look in that file, it is in the correct place, as far as I can tell. More detail of the code is below:
MyInputMethodService.java:
This also has the import statements above the included code.
public class MyInputMethodService extends InputMethodService implements KeyboardView.OnKeyboardActionListener {
#Override
public View onCreateInputView() {
KeyboardView keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard_view, null);
Keyboard keyboard = new Keyboard(this, R.xml.number_pad);
keyboardView.setKeyboard(keyboard);
keyboardView.setOnKeyboardActionListener(this);
return keyboardView;
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.marcel54.keyboard3">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
android:fullBackupContent="true">
<activity android:name="com.marcel54.keyboard3.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:label=".MyInputMethodService"
android:name="com.marcel.keyboard.MyInputMethodService"
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>
Would this be stopping my keyboard from running once installed?

Related

Android Studio android:label for a differnet activity does not display the app name [does not work]

I am trying to have a different app name for an Activity "My Profile Photo" but it does not seem to show up even when I have given android:label="My Profile Pic" to that particular activity
The Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aditya.myprofile">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:label="My Profile">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ProfilePhoto"
android:label="Profile Pic" ></activity>
</application>
</manifest>
The XML Design:
The Android App name space is empty
Where am I going wrong?
Try this add title through java code add this code in your activity like this
getSupportActionBar().setTitle("My Profile");
I think you need to set a theme to your activity in your manifest.
<activity android:name=".ProfilePhoto"
android:theme="#style/AppTheme"
android:label="#string/profilePicture></activity>
Another solution : in your activity in onCreate you need to call :
getSupportActionBar().setTitle("Your Activity Title");

Its a way to cover the bar on the top or remove it?

Hello everyone i have a question can i remove this bar or cover it?
its anoying when i go back in the app it shows the bar, when i open the app then its normal.Can someone help me?
I searched around of the internet and i cant find any question about it to remove the tiny bar on the top.
When you can help me please write it down.
Here is the manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.minecraft_pc.test">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Try do it programmatically:
// as the doc page says, this is a solution for Android > 4.1
View view= getWindow().getDecorView();
int flagOption = View.SYSTEM_UI_FLAG_FULLSCREEN;
view.setSystemUiVisibility(flagOption);
You can check the relative doc page.

live wallpaper-settings button is not working

okay, this is my very first application which i am working on, everything works fine until i wanted to add a settings button to my live wallpaper, the problem is, when i simply hit "settings" it comes with this message of "live wallpaper picker has stopped". here's my code
Android manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Live.zaki"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.ui.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:label="#string/appName"
android:icon="#drawable/icon">
<service
android:name="com.Live.zaki.CustomWallpaper"
android:label="#string/appName"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/wallpaper" />
</service>
<activity
android:name="com.example.ui.SecondActivity"
android:label="Home" >
</activity>
<activity
android:name=".PrefsActivity"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
</application>
</manifest>
wallpaper.xml
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="#drawable/icon"
android:description="#string/appDescription"
android:settingsActivity="com.Live.zaki.PrefsActivity"
/>
prefs.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="#string/general_lwp_settings">
<CheckBoxPreference
android:key="lwp_o_scroll_lock_key"
android:summary="#string/lwp_o_scroll_lock_summary"
android:title="#string/lwp_o_scroll_lock_title"
android:defaultValue="false" />
<CheckBoxPreference
android:key="lwp_auto_animation_key"
android:summary="#string/lwp_auto_animation_summary"
android:title="#string/lwp_auto_animation_title"
android:defaultValue="false" />
</PreferenceCategory>
PrefsActivity.java
public class PrefsActivity extends PreferenceActivity{#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(com.Live.zaki.R.xml.prefs);
}
}
i haven't yet configured any preference logic on my main livewallpaper.java code, i just want that settings menu to popup "two checkbox in my case". Is this even possible ??
if anyone could help me, that would great !! tips, tutorials anything !!
here's my application results without settings,
https://drive.google.com/file/d/0B44QwXQHh5irNFRnYkhzdDhPM00/edit?usp=sharing
buddy add exported flag in setting activity and set it true android:exported="true"
change the package name in your xml folder wallpaper.xml file to a fully qualified name.
android:settingsActivity="yourPackagename.PrefsActivity"
in the Manifest file add:
<activity
android:exported="true"
android:name=".PrefsActivity"
android:theme="#android:style/Theme.Black.NoTitleBar">

ActivityNotFoundException while using startActivity(Intent)

Here's the error, referring to where I call startActivity(Intent):
`05-17 01:40:37.918: E/AndroidRuntime(12997):android.content.ActivityNotFoundException:
Unable to find explicit activity class {/com.rhombi.Menu}; have you declared
this activity in your AndroidManifest.xml?
Here's how I use startActivity(Intent) in com.rhombi.Intro:
startActivity(iMenu);
Here's how I declare it earlier, in the same class:
public Intent iMenu = new Intent(this, Menu.class);
Here's how I declare it all in my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rhombi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name=".Intro"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
I've searched through a TON of other questions about this and I can't seem to figure out what the issue is. The one thing that makes my issue unique is that little forward slash when it tells me that it's unable to find the explicit activity class ("{/com.rhombi.Menu}"). That never showed up in my searches, but I appear to be doing everything right.
There was something wrong with the this you passed as a Context to the Intent constructor, as evidenced by the empty package name in ComponentInfo {/com.rhombi.Menu} - there's just the class name.
try changing
android:name=".Menu" to android:name="{package name}.Menu"

AndroidManifest.xml with multiple application tags

I'm very new to Android programming and I've been trying to figure out why my app is force-closing on a button-click. I've narrowed it down to a few things.
One question; Is it possible to have more than one <application> tag in the manifest xml?
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dummies.android.beergoggles"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Result" android:label="#string/app_name"> </activity>
</application>
<application android:name="MyApp"
android:icon="#drawable/icon"
android:label="#string/app_name2"></application>
I've been researching, but found only a vague post about creating a new manifest file for a new application. The MyApp application is just an app for a "global variable", since I guess there's no way to do that without a new application.
Here is the code for MyApp in case it helps:
import android.app.Application;
public class MyApp extends Application{
public static int resultCount;
public int getCount(){
return resultCount;
}
public void setCount(int c){
resultCount = c;
}
}
Any help would be much appreciated.
According to documentation manifest file with only one application element is valid.
Only the <manifest> and <application> elements are required, they each
must be present and can occur only once.
What I think you want is to use your custom Application as the main Application.
So you dont add a new <application> but just specify its name to the main <application>(you need to specify its full package).
<application android:icon="#drawable/icon" android:label="#string/app_name" android:name:"com.mypackage.MyApp"> <!-- Added the android:name -->
<activity android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Result" android:label="#string/app_name"> </activity>
</application>
See info here
Only the 'manifest' and 'application' elements are required, they each must be present and can occur only once. Most of the others can occur many times or not at all — although at least some of them must be present for the manifest to accomplish anything meaningful.

Categories

Resources