Ola pessoal nãoestou conseguindo recuperar valores do meu texView ao clicar no ListView
public class MainActivity extends BaseActivity implements LockMainContract.View, View.OnClickListener {
private ImageView btn_setting;
private TabLayout tab_layout;
private ViewPager view_pager;
private MainActivity.PagerAdapter mPagerAdapter;
private LockMainPresenter mLockMainPresenter;
private List<String> titles;
private List<Fragment> fragmentList;
private static final int REQUEST_CODE = 0;
private DevicePolicyManager mDPM;
private ComponentName mAdminName;
//admob
//AdView adView;
@Override
public int getLayoutId() {
return R.layout.activity_laucher;
}
@Override
protected void initViews(Bundle savedInstanceState) {
try {
// Initiate DevicePolicyManager.
mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
mAdminName = new ComponentName(this, DeviceAdminDemo.class);
if (!mDPM.isAdminActive(mAdminName)) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mAdminName);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Clique no botão Ativar para proteger seu aplicativo de desinstalação por terceiros não autorizados.");
startActivityForResult(intent, REQUEST_CODE);
} else {
// mDPM.lockNow();
// Intent intent = new Intent(MainActivity.this,
// TrackDeviceService.class);
// startService(intent);
}
} catch (Exception e) {
e.printStackTrace();
}
btn_setting = findViewById(R.id.btn_setting);
tab_layout = findViewById(R.id.tab_layout);
view_pager = findViewById(R.id.view_pager);
mLockMainPresenter = new LockMainPresenter(this, this);
mLockMainPresenter.loadAppInfo(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(MainActivity.this)) {
Intent intents = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(intents, 0);
Toast.makeText(MainActivity.this, "Permitir esta permissão para exibir tela de bloqueio", Toast.LENGTH_SHORT).show();
}
}
//admob
// adView = findViewById(R.id.adView);
// AdUtils.initAd(MainActivity.this);
// AdUtils.loadBannerAd(adView);
// AdUtils.loadInterAd(MainActivity.this);
}
@Override
protected void initData() {
PowerManager powerManager = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (powerManager != null && !powerManager.isIgnoringBatteryOptimizations(AppConstants.APP_PACKAGE_NAME)) {
@SuppressLint("BatteryLife")
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + AppConstants.APP_PACKAGE_NAME));
startActivity(intent);
}
}
if(!BackgroundManager.getInstance().init(this).isServiceRunning(LockService.class)){
BackgroundManager.getInstance().init(this).startService(LockService.class);
}
BackgroundManager.getInstance().init(this).startAlarmManager();
}
@Override
protected void initAction() {
btn_setting.setOnClickListener(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public void loadAppInfoSuccess(@NonNull List<CommLockInfo> list) {
int sysNum = 0;
int userNum = 0;
for (CommLockInfo info : list) {
if (info.isLocked()==false) {
sysNum++;
} else {
userNum++;
}
}
titles = new ArrayList<>();
titles.add("Aplicativos " + " (" + sysNum + ")");
// titles.add("Seus aplicativos" + " (" + userNum + ")");
SysAppFragmentLauncher sysAppFragmentLauncher = SysAppFragmentLauncher.newInstance(list);
// UserAppFragment userAppFragment = UserAppFragment.newInstance(list);
fragmentList = new ArrayList<>();
fragmentList.add(sysAppFragmentLauncher);
// fragmentList.add(userAppFragment);
mPagerAdapter = new MainActivity.PagerAdapter(getSupportFragmentManager(), fragmentList, titles);
view_pager.setAdapter(mPagerAdapter);
tab_layout.setupWithViewPager(view_pager);
}
@Override
public void onClick(@NonNull View view) {
switch (view.getId()) {
case R.id.btn_setting:
// AdUtils.showInterAd(MainActivity.this, new Intent(this, SplashUnlockActivity.class));
Intent intent = new Intent(MainActivity.this, SplashUnlockActivity.class);
intent.putExtra(AppConstants.LOCK_PACKAGE_NAME, AppConstants.APP_PACKAGE_NAME);
intent.putExtra(AppConstants.LOCK_FROM, AppConstants.LOCK_FROM_LOCK_MAIN_ACITVITY);
startActivity(intent);
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
}
}
public class PagerAdapter extends FragmentStatePagerAdapter {
private List<Fragment> fragmentList ;
private List<String> titles ;
public PagerAdapter(FragmentManager fm, List<Fragment> fragmentList, List<String> titles) {
super(fm);
this.fragmentList = fragmentList;
this.titles = titles;
}
//@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public CharSequence getPageTitle(int position) {
return titles.get(position);
}
@Override
public int getCount() {
return titles.size();
}
}
public void onItemClick(AdapterView<?> adapter, View view,
int position, long id) {
int cheeses = position;
if (cheeses == 0) {
Toast.makeText(getApplicationContext(), "teste.toString()", Toast.LENGTH_SHORT).show();
}
}
public void onClick2(View v) {
//Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.youtube");
// if (launchIntent != null) {
// startActivity(launchIntent);//null pointer check in case package name was not found
// }
// Integer teste = v.getId();
//Toast.makeText(getApplicationContext(), teste.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onBackPressed() {
}
}