Click here to Skip to main content
15,882,278 members
Home / Discussions / Android
   

Android

 
QuestionAlarm Manager Pin
Pavlex429-Jan-17 0:40
Pavlex429-Jan-17 0:40 
AnswerRe: Alarm Manager Pin
Richard MacCutchan29-Jan-17 2:01
mveRichard MacCutchan29-Jan-17 2:01 
GeneralRe: Alarm Manager Pin
Pavlex429-Jan-17 2:13
Pavlex429-Jan-17 2:13 
GeneralRe: Alarm Manager Pin
Richard MacCutchan29-Jan-17 2:18
mveRichard MacCutchan29-Jan-17 2:18 
GeneralRe: Alarm Manager Pin
Afzaal Ahmad Zeeshan29-Jan-17 2:22
professionalAfzaal Ahmad Zeeshan29-Jan-17 2:22 
GeneralRe: Alarm Manager Pin
Richard MacCutchan29-Jan-17 2:47
mveRichard MacCutchan29-Jan-17 2:47 
GeneralRe: Alarm Manager Pin
Afzaal Ahmad Zeeshan29-Jan-17 3:07
professionalAfzaal Ahmad Zeeshan29-Jan-17 3:07 
AnswerRe: Alarm Manager Pin
Afzaal Ahmad Zeeshan29-Jan-17 2:20
professionalAfzaal Ahmad Zeeshan29-Jan-17 2:20 
First of all, my recommendation is to consider using the FileObserver in Android, instead of triggering that each second to check if there are files or not. That is a good approach towards going through what you want to do.

Secondly, as Richard mentioned, the reason is that the list object is not null, that doesn't mean its count or length or size is also zero. Just to show you what I really mean, here is a sample code,
Java
File directory = new File("/path/to/folder");
File[] contents = directory.listFiles();

if(contents == null) {
   // directory not found
} else if(contents.length == 0) {
   // directory exists, but no files
} else {
   // has further content, down the tree.
}
You can update your code, to meet this structure and then show the Toast notifications in Android. So kindly implement these two things, first of all that service will help you not throttle CPU every second.

For an example of FileObserver please see: java - How do you implement a FileObserver from an Android Service - Stack Overflow.
file io - How to check if a directory is empty in Java - Stack Overflow
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~

GeneralRe: Alarm Manager Pin
Pavlex429-Jan-17 3:40
Pavlex429-Jan-17 3:40 
AnswerRe: Alarm Manager Pin
Afzaal Ahmad Zeeshan29-Jan-17 3:56
professionalAfzaal Ahmad Zeeshan29-Jan-17 3:56 
GeneralRe: Alarm Manager Pin
Pavlex429-Jan-17 4:00
Pavlex429-Jan-17 4:00 
GeneralRe: Alarm Manager Pin
Pavlex429-Jan-17 4:54
Pavlex429-Jan-17 4:54 
AnswerRe: Alarm Manager Pin
David Crow30-Jan-17 10:25
David Crow30-Jan-17 10:25 
GeneralRe: Alarm Manager Pin
Pavlex430-Jan-17 10:40
Pavlex430-Jan-17 10:40 
AnswerRe: Alarm Manager Pin
David Crow30-Jan-17 16:50
David Crow30-Jan-17 16:50 
GeneralRe: Alarm Manager Pin
Pavlex431-Jan-17 10:48
Pavlex431-Jan-17 10:48 
SuggestionRe: Alarm Manager Pin
David Crow31-Jan-17 17:23
David Crow31-Jan-17 17:23 
GeneralRe: Alarm Manager Pin
Pavlex431-Jan-17 20:22
Pavlex431-Jan-17 20:22 
QuestionRe: Alarm Manager Pin
David Crow1-Feb-17 2:14
David Crow1-Feb-17 2:14 
QuestionAndroid OTG Detect App Pin
Pavlex427-Jan-17 10:54
Pavlex427-Jan-17 10:54 
AnswerRe: Android OTG Detect App Pin
Richard MacCutchan27-Jan-17 22:05
mveRichard MacCutchan27-Jan-17 22:05 
QuestionSimple HTTP Post Request - application/json Pin
Django_Untaken27-Jan-17 9:21
Django_Untaken27-Jan-17 9:21 
AnswerRe: Simple HTTP Post Request - application/json Pin
Richard MacCutchan27-Jan-17 22:03
mveRichard MacCutchan27-Jan-17 22:03 
QuestionAndroid USB Detection Pin
Pavlex421-Jan-17 11:18
Pavlex421-Jan-17 11:18 
AnswerRe: Android USB Detection Pin
Afzaal Ahmad Zeeshan21-Jan-17 12:28
professionalAfzaal Ahmad Zeeshan21-Jan-17 12:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.