Sometimes we need to know when fragment is selected and to handle it.
1. Add interface:
public interface FragmentSelection{
void onPageUnSelected();
void onPageSelected();
}
Android Development
Useful diagnostic tool. It helps to find and fix performance issues, object leaks and other runtime issues.
if (BuildConfig.DEBUG) {
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeathOnNetwork()
.build());
}
Example in logs:
D: StrictMode policy violation; ~duration=19 ms:
android.os.StrictMode$StrictModeDiskReadViolation:
policy=543 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1137)
at android.app.SharedPreferencesImpl.awaitLoadedLocked(SharedPreferencesImpl.java:202)
at android.app.SharedPreferencesImpl.getBoolean(SharedPreferencesImpl.java:259)
at .MyApplication.notificationToggleCheck(MyApplication.java:54)
at .MyApplication.onCreate(MyApplication.java:35)
...
http://developer.android.com/reference/android/os/StrictMode.html
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
MainActivity – onCreate()
...
SectionsPagerAdapter mSectionsPagerAdapter =
new SectionsPagerAdapter(getSupportFragmentManager(), numOfPages);
ViewPager viewPager = (ViewPager) findViewById(R.id.container_view_pager);
viewPager.setAdapter(mSectionsPagerAdapter);
viewPager.setCurrentItem(1000 * numOfPages);
...
Add one pixel width transparent border to your image (png).