我希望创建一个显示标签的活动。在一个选项卡上应扫描信标,其他选项卡应承载另一个活动
Java代码
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"
/>
作为个人活动的主要活动会扫描信标并正确显示它们。
beaconmanager.bind(this)在mainactivity onCreate()
中调用我收到错误:
android.os.RemoteException:BeaconManager未绑定到该服务。调用beaconManager.bind(BeaconConsumer consumer)并等待onBeaconServiceConnect()的回调