The PWA Web-push notifications for Android aren't appearing without a title set (body only).
I have a bug that an Android push notification is not multiline.
All the text is set in the notification's title - no surprises.
Splitting the text is kinda difficult as there are really a lot of options with their own variables and localization.
I've tried to set the text into a body instead of a title as it's done for iOS (working fine), and the notification just won't come!
webPushBuilder = new WebPush.Build()
.addBody(localizedText)
.addData(customDictionary);
The pushes arrive with title only and with title+body, but body-only ones don't come.
Is there a way to send them without the title?
From what I found, a title is required to receive a Push notification on Android.
Setting title to "\n", " ", "" won't work either.
Related
I am a newbie of Android Studio.
I have a problem with display the logs in my app.
For example:
String timeStamp = new
SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cycle);
TextView textView = (TextView) findViewById(R.id.cykleoncreate);
Log.d("[ " + timeStamp + "]", "[onCreate]");
I only want to display this log in my app. How can I do it?
you can display the logs by Toast or set in textView
Toast.makeText(getApplicationContext(),timeStamp,Toast.LENGTH_SHORT).show();
or
textView.setText(timeStamp);
What you have done is write but you can get confused as in where's the log, Log has tag and message, Tags are usually Activity or fragment name so that its easier for one to locate from where did a particular error or message came from, and you can include anything in the message part of it.
we have different types of logs this can be found here
You will find a logcat button on bottom side left side of android studio from there you can select depending on which type you want to see? in your case it's debug
Ok, it works well
textView.setText(timeStamp)
But I don't know why it doesn't work, when I want to build my string:
textView.setText(timeStamp + "my string")
Actually Log is not displaying in app , it will display in android studio . For displaying in app , we need to use Toast . your code is working fine you can check it in your android studio , as its shown in image We can display like this Log.d("onCreate", timeStamp); and search using TAG as onCreate.
I send sms using java with smslib library, that contain code that i want to copy when sms received from my android device.
here is my code
String stringMessage = "code : xxxxxxyyyyyzzzzzz \n"
+ "any question : http:/sitamvan.com";
String number = "08888888888";
OutboundMessage msg = new OutboundMessage(number, stringMessage);
Service.getInstance().sendMessage(msg);
for example the text on the sms will be like this
code : xxxxxxyyyyyzzzzzz
any question : http:/sitamvan.com
when i received the sms (i opened it with default sms app), the url is blue in color and can be copied just by tap on it and the copy option will be popped up.
is it possible to make my code blue in color too? so the default sms app read my code as some copyable text just like when number or link is present on it? may be by adding some text or enclose it with apostrophe?
I make the notification display and encounter a problem - some notifications do not have a title and text, for example, a player, some do not have anything in extras, like CleanMaster's notification about installing the application.
CharSequence title = (CharSequence)nf.extras.get("android.title");
CharSequence text = (CharSequence)nf.extras.get("android.text");
In my app which has tabbed activity, I am sending a simple message to textView and logcat (message indicating which tab I am selecting).
However, textView shows correct string but logcat shows different one.
Steps to reproduce this problem are very simple:
Start a new Android Studio project (My Android Studio version: 1.5.1)
Give any application name (e.g. MyApplication)
Keep only "Phone and Tablet" selected
Select "Tabbed Activity"
Choose Navigation Style "Action Bar Tabs (with View Pager)"
Click finish
This will generate and build project. If we run this application it will show string "Hello World from section: 1" on first tab, "Hello World from section: 2" on second and "Hello World from section: 3" on third tab.
Now, go in MainActivity.java and in method onCreateView (of class PlaceholderFragment) just below this line (where it send string to textView),
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
add this line
Log.i("onCreateView", "From tab number: " + getArguments().getInt(ARG_SECTION_NUMBER));
Expected behaviour:
textView and logcat both should display same message as we tap on tabs.
Actual behaviour:
textView shows correct strings. However in logcat, tab numbers shown are incorrect and hence not in consistent with textView output.
This is indeed weird and height of all is, instead of this when I tried forming string on my own and passing it to textView and LogCat
String strMessage = "Msg from tab number: " + getArguments().getInt(ARG_SECTION_NUMBER);
textView.setText (strMessage);
Log.i("onCreateView", strMessage);
It still has SAME behaviour i.e. shows correct strings in textView for relevant tabs but Logcat shows completely different tab numbers. Same string I am sending but only number changes ???
I found root cause of this on my own. Looks like textView.setText called in onCreateView sets the text value and it never changes afterwards. I wanted to find out which tab currently is active or visible so that I could update its contents. And I was under wrong impression that onCreateView gets called when tab is visible. Finally I found this answer which solved my problem.
I am trying to follow the gcm tutorial from Googles docs. They say to call this method if Play Services are out of date:
GooglePlayServicesUtil.getErrorDialog(resultCode, activity, 9000).show();
That's fine, but it puts a dialog that says "This app won't run unless you update Google Play Services" with an "Update" button. I want to change the title and the message text. My users CAN skip the update, and the app will still run. They just won't get push notifications. How do I change the message of the dialog?
I would like to do something like:
Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity, 9000);
errorDialog.setTitle("out of date");
errorDialog.setMessage("Please update or push notifications won't work. Thank you");
errorDialog.show();
You can override desired string value in your application's strings.xml like this. Simply add these lines in your strings.xml
For message on dialog
<string name="common_google_play_services_update_text" msgid="448354684997260580">This app won\'t run unless you update Google Play services.</string>
For title on dialog
<string name="common_google_play_services_update_title" msgid="6006316683626838685">out of date</string>
EDIT
You could find more information here
http://blog.elsdoerfer.name/2010/04/08/android2po-managing-android-translations/
and What's the meaning of attribute 'msgid' in strings.xml?
msgid is used in android internal strings for localization but I never found any documentation about it. Two reference I have as above. I believe if you remove the msgid still it would work, although I never tried it.
The source of this code is
android_sdk\extras\google\google_play_services\libproject\google-play-services_lib\res\values\common_strings.xml