[android-developers] Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

2016-08-08 Thread Darshan Phy

Hey everyone,

The requirement was to make a custom notification since the android's 
default notification only allows for an image. So I went through on how to 
attach a custom UI for notification when expanded, the ready answer was to 
create a custom view and pass to the notification manager and allowed from 
API level 16.
So I did one and here the my layout xml code - filename: 
notification_custom_view_new:

http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/GhostWhite;>


























The way I referenced it in code:

private RemoteViews assignRemote(Bitmap bitmap, String title, String message
){
  RemoteViews expandedView = new RemoteViews(Application.getInstance().
getPackageName(), R.layout.notification_custom_view_new);
  expandedView.setTextViewText(R.id.title, title);
  expandedView.setTextViewText(R.id.message, message); expandedView.
setImageViewBitmap(R.id.big_picture, bitmap);
  expandedView.setImageViewResource(R.id.big_icon, R.mipmap.ic_launcher);
  expandedView.setTextViewText(R.id.time, getOnlyHrsMin());
  return expandedView;
}


assigning customview to notification manager:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
notification.bigContentView = assignRemote(bitmap, title, message);
}

But this gave me error saying bad notification, I have identified over 15+ 
same question here on stackoverflow without a right answer.. Some suggest 
it to be a resource missing and hence the error. I am sure from my end none 
of the values are null nor resources missing errors are not there in my 
remote view that is passed.

Any help will be appreciated and also I have tried for around a couple of 
days to track the error but nothing good seems to happen. Please help me!

Screenshot attached for layout UI.. also find the NotificatioUtils and 
layout xml files attached for reference.

Thanks
DJphy



-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/1cc8ccad-f636-4558-9be8-5a83d5598012%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


notification_custom_view_new.xml
Description: XML document
package com.goldadorn.main.dj.support.gcm;

import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.support.v7.app.NotificationCompat;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.util.Patterns;
import android.widget.RemoteViews;

import com.goldadorn.main.R;
import com.goldadorn.main.activities.Application;
import com.goldadorn.main.dj.utils.Constants;
import com.goldadorn.main.dj.utils.DateTimeUtils;
import com.goldadorn.main.dj.utils.IntentKeys;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created by COMP on 2/25/2016.
 */
public class NotificationUtils {

private static String TAG = NotificationUtils.class.getSimpleName();

private static Context mContext;

public NotificationUtils() {
}

public NotificationUtils(Context mContext) {
this.mContext = mContext;
}

public void showNotificationMessage(String title, String message, String timeStamp, Intent intent) {
showNotificationMessage(title, message, timeStamp, intent, null);
}

public void showNotificationMessage(final String title, final String message, final String timeStamp, Intent intent, String imageUrl) {
// Check for empty push message
if (TextUtils.isEmpty(message))
return;


// notification icon
final int icon = R.mipmap.ic_launcher;

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(IntentKeys.PUSH_NOTIFICATION_CALL, Constants.GCM_CALL);
final PendingIntent 

[android-developers] APK size weirdly got increased (increase upto 10 MB)

2016-06-17 Thread Darshan Phy

Hey Hi everyone,

I am currently working on this project for my company.
The initial/usual size of the apk before the weird thing happened was ~10MB
This project uses two external libraries
1. KAndroid (company customised lib, not to worry)
2. PayU - Payment gateway for our app.
Note: I am excluding all the libs from GRADLE dependency (assuming the libs 
thr are not contributing much to the apk size)

But you can check the build.gradle as well I might wrong in assuming.

Issue:
# The entire resources folder is 2.56MB (size on disk) and 1.63MB(size)
# The size of the APK suddenly, drastically and weirdly got increased by 
10MB last week and now the size of the APK is ~20MB.
# No extra libs have been added since 6 months back. The KAndroid lib was 
always there from the beginning, PayU sdk (payment gateway lib) was added 
months back.
# The sdk PayU's build folder is around ~20MB, this could have been a 
suspect but it was added months back as I said and so the APK size must 
have been increased initially only and not in the last week

link to my entire project on drive; please feel free to checkout: 
https://drive.google.com/open?id=0B-lDLHmPjFIwS0U0NVZnVTRPYjQ
I could have linked to the same project at bitbucket but since last few 
days i haven't pushed the code yet... Sorry about the huge size of zip file 
on drive

It will be a great help if someone can find me a solution.
Awaiting your responses
Thanks a ton 

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/b2264f43-e044-4565-aea3-cf4a85139833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.