Problem: I'm developing content display app. Now I want to enable GCM push notification app, for that I downloaded a sample project from
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
The sample project is working fine and notification are coming as expected.
Now I copy pasted the following files to my project
1. manifest file
2. xml file
3. values file
4. MainActivity file
I changed the Packagename that I need from the pervious code that I copied but still it is not working. Please guide me which line i should change the packagename of project , where I should use class packagename and in where i should use the project packagename.
It is giving me error because the package name and sub package name are same.
Code:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<!-- Register Activity -->
<activity
android:name="com.androidhive.pushnotifications.RegisterActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main Activity -->
<activity
android:name="com.androidhive.pushnotifications.MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name" >
</activity>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.androidhive.pushnotifications" />
</intent-filter>
</receiver>
<service android:name="com.androidhive.pushnotifications.GCMIntentService" />
</application>
being a newbie in android development, I'm not able to figure out which is the main package name in this code.
Any suggestion would be great!. thanks in advance
We add it like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mymain.package"
android:versionCode="1"
android:versionName="1.0" >
Sarthak Mittal is right, but you also need to change your manifest for main activity:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mymain.package"
android:versionCode="1"
android:versionName="1.0" >
<activity
android:name="com.androidhive.pushnotifications.MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Related
This is my AndroidManifiest.xml File
Their is 2 error
no resource identifier found for attribute 'launchmode' in package android
no resource identifier found for attribute 'stateNotNeeded' in package android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="a52.puri.fbkunal.com.launcher">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:stateNotNeeded="true"
android:
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
</application>
</manifest>
You are assigning unknown property for application tag, launchMode in android is for Activities. Activities launch and visible to user but Application launch only once when you start your App. You can say Application is a start point in Android App.
Assign a launchMode into Activity not in application tag.
Basically we could assign a launchMode directly as an attribute of <activity> tag inside AndroidManifest.xml file list this:
<activity
android:name=".SingleTaskActivity"
android:label="singleTask launchMode"
android:launchMode="singleTask">
When they tell me to add default activity class name, should I write com.example.milanovic.hellou.MainActivity or MainActivity or .MainActivity.
com.example.milanovic.hellou is the name of the package I'm using.
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
From my understanding, since you specify your package in the AndroidManifest.xml file, the MainActivity's package should be specified relatively to that. For example, if you package is com.example.app and your activity is com.example.app.Activity, then you can type it as .Activity(without dot is also fine), but if it is different, then full package as totally.different.package.Activity, if it is subpackage, try: .subpackage.name.Activity
Finally in your case it is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.milanovic.hellou">
...
<application ...>
<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>
So I have very weird problem with android app that I developed that I really do not understand how to address.
Description of the problem: When I run the app in my emulator(and many other emulators) the app works perfectly, but when I list it on Google Play and some user download the app, it automatically crashes. so I just wonder if my androidmainfest is properly written.
*the program written in esclipse, java, android.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app"
android:versionCode="6"
android:versionName="1.5" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.example.MainActivity"
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="com.example.SurfaceExampleView"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.example.start" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.RulesGame"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.rules" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.PolicyGame"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.policy" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.RevenueGame"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.revenue" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.ShopGame"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.shop" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
You have posted only your manifest and not the logs. My guesses based on that is the problem may be within your package declaration, rest everything seems fine.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app".....
The package should be unique and its like what we call package in java world. You have declared it as com.app whereas your app is using com.example.... package. Also com.app maybe used by other app.The package name defines your application's identity.
Once you publish your application, you cannot change the package name. As the package name defines your application's identity, so if you change it, then it is considered to be a different application and users of the previous version cannot update to the new version. So you may have to upload another app with different package name.
Try getting logs(use crashlytics) for your crash and we can look into it for the root cause.
In eclipse, if you press CTRL and click the method name, you can open declaration or implementation of this method. I want to use this idea to navigate to a class in android manifest.xml.
All other Activity or Service work just fine, but only Receiver does not.
see code below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.seafile.seadroid2"
android:versionCode="20"
android:versionName="1.0.1"
android:installLocation="internalOnly"
>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:name="com.seafile.seadroid2.SeadroidApplication"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<receiver android:name=".OSBootReceiver" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name="com.seafile.seadroid2.BrowserActivity"
android:label="#string/app_name"
android:theme="#style/Theme.SeafileTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.seafile.seadroid2.sync.CameraUploadService" > </service>
</application>
</manifest>
I checked if the path was right, the class exists in that path, so why can't I click to open that class?
Anyone can help?
Your receiver is not using the full path. Try changing the declaration from:
<receiver android:name=".OSBootReceiver" >
...
</receiver>
to:
<receiver android:name="com.seafile.seadroid2.OSBootReceiver" >
...
</receiver>
I've found that Eclipse will only respond to a ctrl-click in a manifest file if the name is fully qualified.
Controls if all the check are enabled.
see
General > Editors > Text Editors > Hyperlinking preference page.
I have an Android widget (it is shown in the list of widgets on the phone, and is not shown in the list of apps). It has a button which launches a pop-up activity.
Now I would like to change the widget so, that it would be both an app (which will be shown in the list of apps on the phone) which will start from that pop-up activity, and a widget (the same as before) which will launch the app (which will consist of that pop-up activity, but will be displayed and treated like an app).
What changes should I make in my manifest file to make the changes described above?
Below is my manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar" >
<receiver android:name="myapp.myapp.MyWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/demo_widget_provider" />
</receiver>
<receiver
android:name="myapp.myapp.MyWidgetIntentReceiver"
android:label="widgetBroadcastReceiver" >
<intent-filter>
<action android:name="GET_HELP" />
<action android:name="CHANGE_PICTURE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/demo_widget_provider" />
</receiver>
<activity
android:name="myapp.myapp.MainActivity"
android:label="#string/title_activity_main" >
</activity>
<activity
android:name="myapp.myapp.CardsChoice"
android:label="#string/title_activity_choice" >
</activity>
</application>
The solution was rather simple: I just needed to add a Launcher Activity to the app.
This operation consists of 2 steps:
Adding activity definition as a launcher activity to the Manifest
Example:
<activity
android:name="package.package"
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>
Adding code of the activity (and the layout) to the app.
It is about an class MainActivity and a layout file activity_main.xml