4

I wish to create an activity which displays tabs. on one tab beacons should be scanned and other tab should host another activity

Java Code

package com.example.root.myperformancearrayadapter;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;


import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

import org.altbeacon.beacon.BeaconManager;
public class NewMainActivity extends TabActivity {

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Resources ressources = getResources();
    TabHost tabHost = getTabHost();

    // Android tab
    Intent intentAndroid = new Intent().setClass(this, MainActivity.class);
    TabHost.TabSpec tabSpecAndroid = tabHost
                .newTabSpec("Android")
                .setIndicator("", ressources.getDrawable(R.drawable.icon_android_config))
                .setContent(intentAndroid);
            startService(intentAndroid);



    // Apple tab
    Intent intentApple = new Intent().setClass(this, AppleActivity.class);
    TabHost.TabSpec tabSpecApple = tabHost
                .newTabSpec("Apple")
                .setIndicator("", ressources.getDrawable(R.drawable.icon_apple_config))
                .setContent(intentApple);
            startService(intentApple);




    // add all tabs
    tabHost.addTab(tabSpecAndroid);
    tabHost.addTab(tabSpecApple);

    //set Windows tab as default (zero based)
    tabHost.setCurrentTab(2);
    }

}

AndroidManifest.xml

    <receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
        <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
    </intent-filter>
    </receiver>

    <service
        android:name="org.altbeacon.beacon.service.BeaconService"
        android:enabled="true"
        android:exported="false"
        android:isolatedProcess="false"
        android:label="beacon"
    />
    <service
        android:name="org.altbeacon.beacon.BeaconIntentProcessor"
        android:enabled="true"
        android:exported="false"
    />

mainactivity as an individual activity scans beacons and displays them properly.

beaconmanager.bind(this) is called in mainactivity onCreate()

I am getting the error:

android.os.RemoteException: The BeaconManager is not bound to the service. Call beaconManager.bind(BeaconConsumer consumer) and wait for a callback to onBeaconServiceConnect()

chubao
  • 5,871
  • 6
  • 39
  • 64
Utkarsha
  • 41
  • 2
  • 1
    The bind call you mention in the description does not appear in the code shown. Also, tge re is no code shown that would cause the Exception you mention. Did you show the right code? – davidgyoung Mar 05 '16 at 11:18

0 Answers0