0

Androidアプリ内にプッシュボット通知を追加しようとしています。しかし、この行がエラーPushbots.sharedInstance().init(this);を与えるアプリはタブレイアウト(断片)パッケージの受信者がありません - プッシュボット通知

を持って

MainActivity.java内であればそこに同じコードが動作するかどうかアプリでノーフラグメント

Logcat No receiver for package com.akapoor.kiittimetabletest1

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    toolbarButton = (Button) findViewById(R.id.toolBarButton); 

    Pushbots.sharedInstance().init(this); 

    // 
    if (ContextCompat.checkSelfPermission(MainActivity.this, 
      Manifest.permission.WRITE_EXTERNAL_STORAGE) 
      != PackageManager.PERMISSION_GRANTED) { 

     // Should we show an explanation? 
     if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, 
       Manifest.permission.WRITE_EXTERNAL_STORAGE)) { 

      // Show an expanation to the user *asynchronously* -- don't block 
      // this thread waiting for the user's response! After the user 
      // sees the explanation, try again to request the permission. 

     } else { 

      // No explanation needed, we can request the permission. 

      ActivityCompat.requestPermissions(MainActivity.this, 
        new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 
        MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); 

      // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an 
      // app-defined int constant. The callback method gets the 
      // result of the request. 
     } 
    } 

    // 
    toolbar = (Toolbar) findViewById(R.id.toolBar); 
    setSupportActionBar(toolbar); 
    getSupportActionBar().setDisplayShowTitleEnabled(false); 

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
    actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close); 
    drawerLayout.addDrawerListener(actionBarDrawerToggle); 
    navigationView = (NavigationView) findViewById(R.id.navigation_view); 
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { 
     @Override 
     public boolean onNavigationItemSelected(MenuItem item) { 
      switch (item.getItemId()) { 
       case R.id.holiday_list: 
        Intent intent = new Intent(MainActivity.this, HolidayList.class); 
        startActivity(intent); 
        drawerLayout.closeDrawers(); 
        break; 
      } 
      return true; 
     } 
    }); 

    tabLayout = (TabLayout) findViewById(R.id.tabLayout); 
    viewPager = (ViewPager) findViewById(R.id.viewPager); 
    viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); 
    viewPagerAdapter.addFragments(TimeTableFragment.newInstance("MONDAY"), "MONDAY"); 
    viewPagerAdapter.addFragments(TimeTableFragment.newInstance("TUESDAY"), "TUESDAY"); 
    viewPagerAdapter.addFragments(TimeTableFragment.newInstance("WEDNESDAY"), "WEDNESDAY"); 
    viewPagerAdapter.addFragments(TimeTableFragment.newInstance("THURSDAY"), "THURSDAY"); 
    viewPagerAdapter.addFragments(TimeTableFragment.newInstance("FRIDAY"), "FRIDAY"); 
    viewPagerAdapter.addFragments(TimeTableFragment.newInstance("SATURDAY"), "SATURDAY"); 
    viewPager.setAdapter(viewPagerAdapter); 
    tabLayout.setupWithViewPager(viewPager); 
} 

マニフェスト

<?xml version="1.0" encoding="utf-8"?> 

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<!-- GCM requires a Google account. --> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 

<permission 
    android:name="com.akapoor.kiittimetabletest1.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 
<uses-permission android:name="com.akapoor.kiittimetabletest1.permission.C2D_MESSAGE" /> 
<!-- This app has permission to register and receive dataf message. --> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name=".MainActivity" 
     android:screenOrientation="portrait"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
     <intent-filter> 
      <action android:name="com.akapoor.kiittimetabletest1.MESSAGE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity android:name=".ClassDataProvider"> 
    </activity> 
    <activity android:name=".HolidayList"></activity> 
    <activity android:name=".AcademicCalendar"></activity> 
</application> 

<receiver 
    android:name="com.pushbots.google.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.akapoor.kiittimetabletest1" /> 
    </intent-filter> 
</receiver> 
<receiver android:name="com.pushbots.push.DefaultPushHandler" /> 

<service android:name="com.pushbots.push.GCMIntentService" /> 
</manifest> 

答えて

0

あなたがtheseが欠けているように見えます。

<receiver android:name="com.pushbots.google.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.example.sampleapp" /> 
    </intent-filter> </receiver> 
<receiver android:name="com.pushbots.push.DefaultPushHandler" /> 
<service android:name="com.pushbots.push.GCMIntentService" /> 
関連する問題