My dashclock notification disappears - android

I am building an app to help you keep track of tv-shows.
When i first add my "widget" to dashclock the notification appear if there is any, but after a while they disappear again.
The code for my activity extending DashClockExtension
#Override
protected void onUpdateData(int reason) {
DatabaseHandler databaseHandler = new DatabaseHandler(this);
ArrayList<Episode> episodes = databaseHandler.GetTodaysEpisodes();
DateHelper dateHelper = new DateHelper();
String numberOfEpisodes = "" +episodes.size();
StringBuilder sb = new StringBuilder();
for (Episode episode : episodes) {
sb.append(dateHelper.Episodenumber(episode) + " " + episode.getTitle() + "\n");
}
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.drawable.ic_icon_dashclock)
.visible(!numberOfEpisodes.equals("0"))
.status(numberOfEpisodes)
.expandedTitle(numberOfEpisodes + " episodes airing today")
.expandedBody(sb.toString())
.clickIntent(new Intent("se.ja1984.twee.CalendarActivity_LAUNCH_IT"))
);
}
Since my data isn´t updated that often I´m satisfied with letting DashClock check for updates.
I´m new to android development and are probably doing something wrong :) And I would really appreciate someone pointing me in the right direction!

Okey so I solved it!
When my app starts I set and static integer with the chosen profile which i then use when fetching data from the database. So when my app is killed by the system it tries to fetch data for profile 0 (which never exists).
Thank you Robby and Roman for the help and time invested in this! :)

You are setting visible=false when numberOfEpisodes is "0". That's most likely what is happening. You can debug the extension like you would debug any other app. Just run it in debug, and then attach to your app through ddms.

Related

Google play game services Leaderboard with custom UI using Unity3d plugin of google

We want to display all leaderboard data into our custom created UI for the game. for that we want to access top scores info such as Profile Picture,Score and Name of the player.
All data will be shown in our custom created UI
we are using following unity3d plugin of google
https://github.com/playgameservices/play-games-plugin-for-unity
Please let us know how to access all players data of our game leaderboard
The you link provided has the actual documentation on how to use the plugin. From Accessing Leaderboard data (where you could get the Score) to Getting Player names, where it is mentioned that you could
use Social.LoadUsers() to load the player profile
from there you could get an IUserProfile to get the image and username. Sample from the same link:
internal void LoadUsersAndDisplay(ILeaderboard lb)
{
// get the user ids
List<string> userIds = new List<string>();
foreach(IScore score in lb.scores) {
userIds.Add(score.userID);
}
// load the profiles and display (or in this case, log)
Social.LoadUsers(userIds.ToArray(), (users) =>
{
string status = "Leaderboard loading: " + lb.title + " count = " +
lb.scores.Length;
foreach(IScore score in lb.scores) {
IUserProfile user = FindUser(users, score.userID);
status += "\n" + score.formattedValue + " by " +
(string)(
(user != null) ? user.userName : "**unk_" + score.userID + "**");
}
Debug.log(status);
});
}
With all that said, if you were hoping for a more detailed and precise sample, it'd be considered as too broad here in Stack Overflow and may be voted to be closed.

Android M & Lollipop - Mark missed call as read

I use below code to clear missed calls after I launch my app. In this I get rows affeted is 1. But when i get next missed call, at that time android's stock phone app adds a new notification as "2 new missed calls". Means they are not counting my clear. Am I missing something.
Note: If i launch the stock phone app once, the counter is reset to 0 again.
public boolean markMissedCallsAsRead() {
ContentValues values = new ContentValues();
values.put(CallLog.Calls.NEW, Integer.valueOf(0));
values.put(CallLog.Calls.IS_READ, Integer.valueOf(1));
StringBuilder where = new StringBuilder();
where.append(CallLog.Calls.NEW);
where.append(" = 1 AND ");
//where.append(CallLog.Calls.IS_READ).append(" = 0");
//where.append(" AND ");
where.append(CallLog.Calls.TYPE).append(" = ").append(CallLog.Calls.MISSED_TYPE);
int rows = context.getContentResolver().update(CallLog.Calls.CONTENT_URI, values, where.toString(),
null);
Utilities.writeToLogFile(Constants.LOG_ERROR_LEVEL, "cleared call logs " + rows);
return true;
}
I'm facing the same problem. There is a similar question here:
https://stackoverflow.com/a/26564121/6433463
I'm starting to think (as stated in that thread) that the only way to achieve that is by opening the stock call log (I hope I'm wrong, but couldn't find anything else).

java.lang.IllegalStateException: get field slot from row 0 col 25 failed

I am trying to create a android app using GreenDAO, this is ERP kind of project so practically it is not possible to post all code here, but i am going to share only related code
QueryBuilder<PartyCommunication> partyCommQueryBuilder = partyCommunicationDao.queryBuilder();
partyCommQueryBuilder = partyCommQueryBuilder.where(
PartyCommunicationDao.Properties.CommType.eq("ALERT"),
PartyCommunicationDao.Properties.ReferenceCategory.eq("Low Stock"));
List<PartyCommunication> listOfPartyComm = partyCommQueryBuilder.list();
PartyCommunication daoPartyCommunication = listItr.next();
Long reference_entity_key = daoPartyCommunication.getReferenceEntityKey();
Product product = daoSessionUni.getProductDao().load(reference_entity_key);
ProductDetail productDetail = new ProductDetail(product);
Integer inventoryQOH= productDetail.getInventoryQOH();
I am getting exception in this line
Product product = daoSessionUni.getProductDao().load(reference_entity_key);
When i debug our application i found that it throwing exception from one of our DAO class as below
public Product readEntity(Cursor cursor, int offset) {
Product entity = new Product( //
.
.
.
.
cursor.getShort(offset + 23) != 0, // isSync
cursor.getShort(offset + 24) != 0, // isDeleted
cursor.getString(offset + 25), // createdBy
cursor.getString(offset + 26), // modifiedBy
cursor.isNull(offset + 27) ? null : new java.util.Date(cursor.getLong(offset + 27)), // lastSyncTime
new java.util.Date(cursor.getLong(offset + 28)), // created
new java.util.Date(cursor.getLong(offset + 29)) // modified
);
return entity;
}
In this line
cursor.getString(offset + 25), // createdBy
This is our 25th column of table.I know that all code is not enough to understand what is going wrong and why i am getting this exception , so i am also going to post logcat output
java.lang.IllegalStateException: get field slot from row 0 col 25 failed
at net.sqlcipher.CursorWindow.getString_native(Native Method)
at net.sqlcipher.CursorWindow.getString(CursorWindow.java:382)
at net.sqlcipher.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
at android.database.CursorWrapper.getString(CursorWrapper.java:114)
at com.tarnea.kareeb.model.ProductDao.readEntity(ProductDao.java:273)
at com.tarnea.kareeb.model.ProductDao.readEntity(ProductDao.java:1)
at de.greenrobot.dao.AbstractDao.loadCurrent(AbstractDao.java:417)
at de.greenrobot.dao.AbstractDao.loadUnique(AbstractDao.java:163)
at de.greenrobot.dao.AbstractDao.loadUniqueAndCloseCursor(AbstractDao.java:150)
at de.greenrobot.dao.AbstractDao.load(AbstractDao.java:139)
at com.tarnea.android.DataCleaningService.adjustLowStockAlertTable(DataCleaningService.java:115)
at com.tarnea.sync.kareeb.pharma.syncadapter.SyncManager.performSync(SyncManager.java:970)
at com.tarnea.sync.kareeb.pharma.syncadapter.SyncAdapter.onPerformSync(SyncAdapter.java:96)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:254
Thanks in advance to all.If anybody have some interest to solve my problem then please please ask any further information whatever you want.
Your problem isn't the query. The SQLite-Table simply does only contain 24 columns.
Probably you modified your database schema by adding new columns like createdBy.
Either you forgot to update your db using OpenHelper
Or you had an error in your ALTER TABLE-statements
Or you ran your app with the new schema-version but without your ALTER TABLE-statements yet included (which is practically the same as 1.
Have a look at your database using SqliteManager, to verify your tables have the columns you expect.
If you cannot get your database-file you can simply delete your app with all data or increase your schema-version and use the DevOpenHelper to recreate the whole database.

Program seems to be ignoring lines of code

I need help with this function.
I know that the if statement recognizes my input because it affects the program elsewhere, but I'm not sure what's going on because this particular Log doesn't display anything even in adb logcat.
Other Log statements in the same class file that this function is from display just fine, and the value update does seem to be changing ("show all" blanks it for some reason but I can figure that out after I get the log to work.)
I am unsure how to search for this problem because it is very specific and I have no idea what causes it (probably something simple that I didn't think of, though.)
void command(String input)
{
//do stuff here
//update = whatever
if(input.equalsIgnoreCase("show all"))
{
update=printAllRooms();
Log.i(input, update);
}
else update=input; //just for testing, will delete later
}
the printAllRooms function:
public String printAllRooms() //for debug purposes
{
String result = "";
for (Iterator<Room> iterator = rooms.iterator(); iterator.hasNext();) {
Room current = iterator.next();
result = result + current.toString()+"\n";
Log.i("printallrooms", current.toString());
}
return result;
}
A note on using Log.
The first argument sent to Log is typically a fixed string indicating the name of the class you are in.
So at the top of your class you might define:
private static final String TAG = "MyClassName";
Then you would use TAG for your log statements in that class.
Log.i(TAG, "My input was: " + input + " Update was: " + update;
To put it mildly, your function looks quite odd. Set a breakpoint at your Log statement, run the debugger and then inspect the variable value contained in update. Most likely, printAllRooms() is not doing what you think.
If the iterator doesn't work for you, try using the For-Each loop:
for (Room r : rooms) {
result = result + r.toString()+"\n";
Log.i("printallrooms", r.toString());
}

SpannableStringBuffer limited to 9,999 characters?

My app reads in large amounts of data from text files assets and displays them on-screen in a TextView. (The largest is ~450k.) I read the file in, line-by-line into a SpannableStringBuffer (since there is some metadata I remove, such as section names). This approach has worked without complaints in the two years that I've had the app on the market (over 7k active device installs), so I know that the code is reasonably correct.
However, I got a recent report from a user on a LG Lucid (LGE VS840 4G, Android 2.3.6) that the text is truncated. From log entries, my app only got 9,999 characters in the buffer. Is this a known issue with a SpannableStringBuffer? Are there other recommended ways to build a large Spannable buffer? Any suggested workarounds?
Other than keeping a separate expected length that I update each time I append to the SpannableStringBuilder, I don't even have a good way to detect the error, since the append interface returns the object, not an error!
My code that reads in the data is:
currentOffset = 0;
try {
InputStream is = getAssets().open(filename);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
ssb.clear();
jumpOffsets.clear();
ArrayList<String> sectionNamesList = new ArrayList<String>();
sectionOffsets.clear();
int offset = 0;
while (br.ready()) {
String s = br.readLine();
if (s.length() == 0) {
ssb.append("\n");
++offset;
} else if (s.charAt(0) == '\013') {
jumpOffsets.add(offset);
String name = s.substring(1);
if (name.length() > 0) {
sectionNamesList.add(name);
sectionOffsets.add(offset);
if (showSectionNames) {
ssb.append(name);
ssb.append("\n");
offset += name.length() + 1;
}
}
} else {
if (!showNikud) {
// Remove nikud based on Unicode character ranges
// Does not replace combined characters (\ufb20-\ufb4f)
// See
// http://en.wikipedia.org/wiki/Unicode_and_HTML_for_the_Hebrew_alphabet
s = s. replaceAll("[\u05b0-\u05c7]", "");
}
if (!showMeteg) {
// Remove meteg based on Unicode character ranges
// Does not replace combined characters (\ufb20-\ufb4f)
// See
// http://en.wikipedia.org/wiki/Unicode_and_HTML_for_the_Hebrew_alphabet
s = s.replaceAll("\u05bd", "");
}
ssb.append(s);
ssb.append("\n");
offset += s.length() + 1;
}
}
sectionNames = sectionNamesList.toArray(new String[0]);
currentFilename = filename;
Log.v(TAG, "ssb.length()=" + ssb.length() +
", daavenText.getText().length()=" +
daavenText.getText().length() +
", showNikud=" + showNikud +
", showMeteg=" + showMeteg +
", showSectionNames=" + showSectionNames +
", currentFilename=" + currentFilename
);
After looking over the interface, I plan to replace the showNikud and showMeteg cases with InputFilters.
Is this a known issue with a SpannableStringBuffer?
I see nothing in the source code to suggest a hard limit on the size of a SpannableStringBuffer. Given your experiences, my guess is that this is a problem particular to that device, due to a stupid decision by an engineer at the device manufacturer.
Any suggested workarounds?
If you are distributing through the Google Play Store, block this device in your console.
Or, don't use one massive TextView, but instead use several smaller TextView widgets in a ListView (so they can be recycled), perhaps one per paragraph. This should have the added benefit of reducing your memory footprint.
Or, generate HTML and display the content in a WebView.
After writing (and having the user run) a test app, it appears that his device has this arbitrary limit for SpannableStringBuilder, but not StringBuilder or StringBuffer. I tested a quick change to read into a StringBuilder and then create a SpannableString from the result. Unfortunately, that means that I can't create the spans until it is fully read in.
I have to consider using multiple TextView objects in a ListView, as well as using Html.FromHtml to see if that works better for my app's long term plans.

Categories

Resources