ActiveAndroid setup - java

I'm new to Android and I'm trying to use SQLite with Active Android ORM. I have a simple todo app and I'm following the tutorial to setup active android. However, it doesn't tell you where to actually put your model files.
https://github.com/pardom/ActiveAndroid/wiki/Getting-started
I believe I have my AndroidManifest.xml setup correctly, I don't know where to put the class where you actually setup your models. This snippet was provided in the tutorial but I don't know where it goes
public class MyApplication extends SomeLibraryApplication {
#Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
}
Also, do I create a new file in app/java/com.blahblah and declare my tables there?
Any help on how to structure this would be appreicated

It's really simple really. After you've added your application class, make sure to add it to your manifest:
<application
***android:name=".MyApplication"***
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
As for where you put your models, it doesn't matter really. You can have a following structure:
Just make sure to add any of your model classes to manifest. Here's how my manifest would look for above structure:
<?xml version="1.0" encoding="utf-8"?> <manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dbtest" >
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
<!-- Set a name for your database -->
<meta-data android:name="AA_DB_NAME" android:value="SomeDatabaseName.db" />
<meta-data android:name="AA_DB_VERSION" android:value="5" />
<!-- All of your models (tables) go here, separated by coma -->
<meta-data
android:name="AA_MODELS"
android:value="com.example.dbtest.models.Item, com.example.dbtest.models.Category" />
</application>
</manifest>
I think that's all there is to it.

Related

Custom Keyboard Java - Potential InputMethod problem

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?

Flurry integration Android throwing errors

I'm trying to integrate flurry into my android app. I'm using the recommended setting and have repositories{jcenter()} and
// Required for Flurry Analytics integration
compile 'com.flurry.android:analytics:8.2.0#aar'
// Optional - If you want to use the Ads SDK
compile 'com.flurry.android:ads:8.2.0#aar'
in the gradle as the docs suggest. I keep getting errors in the that Application is not resolved. The docs really blow and I'm not 100% sure what going on. I've never integrated flurry before can someone please help! I put the manifest and the class i'm using below. I know it doesn't have a key I'm still working on removing errors. I'm dumping the that class in the main file for simplicity for now.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tempconversion.october.com.myapplication">
<!-- Required permissions - Internet access -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- Highly Recommended permission - External memory pre-caching -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- Optional permission - Location based ad targeting -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="F to C and K"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
class in main file
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
new FlurryAgent.Builder()
.withLogEnabled(true)
.withCaptureUncaughtExceptions(true)
.withContinueSessionMillis(10)
.withLogLevel(VERBOSE)
.build(this, FLURRY_API_KEY);
}
}
Declare the application name in manifest.xml file.
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="F to C and K"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

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");

Trying to start Google Play Services Games example

I'm very new to Android studio, so this is probably a stupid question.
As of current I'm trying to follow this tutorial:
https://developers.google.com/games/services/android/quickstart
and got stuck at step 1 almost right off the bat. I downloaded the whole project as I'm trying to start and test "Typeanumber". Upon importing I went to "TypeaNumber" and changed the AndroidManifest.XML to a random domain. Quite obviously this didn't change anything. I still can't run the project and there're errors everywhere.
The XML looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pieps.testgame">
<application
android:supportsRtl="true"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity
android:name="com.google.example.games.tanc.MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
In the source, where I find the classes, there're like 5 directories that all seem exceptionally redundant. In the classes the wrong package is displayed as well.
Am I suppose to change all packages throghout the entire project(if so the documentation fails pretty hard)? What am I suppose to do to get this working?

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