2014-11-25 62 views
-1

問題:我正在開發內容顯示應用程序。現在,我想啓用GCM推送通知的應用程序,爲我下載了一個樣本項目從標題:如何在android中區分子包和主包名?

http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

示例項目工作的罰款和通知來了預期。 現在我複製粘貼下列文件到我的項目
1.清單文件
2. xml文件
3.值文件
4. MainActivity文件

我改變了PACKAGENAME,我從透水代碼需要我複製,但仍然無法正常工作。請指導我哪一行我應該改變項目的包名,我應該在哪裏使用類包名和我應該在哪裏使用項目包名。

它給我錯誤,因爲包名稱和子包名稱相同。

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> 

在android開發中是一個新手,我無法弄清楚這個代碼中的主包名。

任何建議將是偉大的!在此先感謝

+0

什麼是確切的錯誤你是接收,你在哪裏看到它? – 2014-11-25 14:44:49

回答

0

我們加入這樣的:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.mymain.package" 
android:versionCode="1" 
android:versionName="1.0" > 
0

Sarthak米塔爾是正確的,但你也需要更改艙單主要活動:

<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>