我没有使用与线程相关的任何内容,但模拟器一直在说:
GO
有一种方法可以调试更多,所以要看看为什么会发生这种错误?
MainActivity:
12-15 14:19:22.807 20983-21204/edu.fontys.stayconnected E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare()
OptionFragmentAdapter:
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
final OptionFragmentAdapter adapter = new OptionFragmentAdapter(getSupportFragmentManager());
if (viewPager != null) {
SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tab_layout);
slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
@Override
public int getIndicatorColor(int position) {
return getResources().getColor(R.color.colorAccent);
}
});
slidingTabLayout.setDistributeEvenly(true);
viewPager.setAdapter(adapter);
slidingTabLayout.setViewPager(viewPager);
}
if (!NotificationManagerCompat.getEnabledListenerPackages(this).contains(getPackageName())) {
new AlertDialog.Builder(this)
.setTitle(getString(R.string.dialog_notification_title))
.setMessage(R.string.dialog_notification_message)
.setPositiveButton(R.string.dialog_notification_settings, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
}
})
.setNegativeButton(R.string.dialog_notification_close_app, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.show();
}
}
}
slidingTabLayout来自谷歌:https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/widget/SlidingTabLayout.java