2014年09月

Checking radio state to newly added array item

I succeeded to implement a radio button using this question by skpal202. But in this question, it only explains how to get the position of selected view clicked which solves the question asked. Adapting that code to my app I encountered difficulties. My question is, are there pointers towards adding selected radio button for new added items in the case of array adapter.



Here the logic being that whenever a newly added item(eg text from an edit text etc) is put into an arrayadapter the radio button checks as true to the newly created item ignoring previously selected item.



N/B all the newly created items should take up radio buttons.





Push notification reaching ios (apns) but not android (gcm) device

So I have a simple Ruby app that uses Rpush to send push notifications to my iphone and my android phone. Right now all it does is sends it to the iphone. I am not sure whether the problem is with my script (i.e. incorrect values for the registration_id, app_name, or auth_key), or whether the problem is how I have my Android app configured.



The relevant part of that code is here (values changed for security - but format/length of keys left untouched to make sure they "look right" to people with experience)



API SETUP/RATIONALE (Sending the notification)

# GCM
app = Rpush::Gcm::App.new
app.name = "MyApp"
app.auth_key = "POfaSyfghilK3l-ueSvRLmbawcRThCWkwmcYGeM"
app.connections = 1
app.save

n = Rpush::Gcm::Notification.new
n.app = Rpush::Gcm::App.find_by_name("MyApp")
n.registration_ids = ["derGV80JK-s:APA91bHgerskBnrhHndes947nMKxI116tC3-k-tGd-hT5NzVc8QAWEkvCrMwrvs78RUL8-vvhp2ultoevqzZnn8gsr9t6WDXDYpGfCliqaJzj0XByBgbi0bm-rYufjcxfCc_5lEL381F"]
n.data = { message: "testing!" }
n.save!

Rpush.push


I determined that the name of my app was "MyApp" by looking at my google developer console here and noticing that the "Project Name" of the desired project is "MyApp".



I determined the Auth Key on the same site, by navigating to API & Auth -> Credentials -> API Key and copy/pasting the API key from there.



I determined my device's registration id using this code in the main activity of my Android App:



public static String getDeviceID(Context context) {
final TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);

final String tmDevice, tmSerial, tmPhone, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "";// + tm.getSimSerialNumber();
androidId = ""
+ android.provider.Settings.Secure.getString(
context.getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);

UUID deviceUuid = new UUID(androidId.hashCode(),
((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();

return deviceId;
}


When logged, getDeviceID shows me the registration id that I specified in the above ruby code.



APP SETUP/RATIONALE (Receiving the notification)

First, I set up my Android Manifest to have all the necessary permissions



<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.johncorser.myapp.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.johncorser.myapp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.johncorser.myapp.permission.C2D_MESSAGE" />


Then, I set up a listener service to react to push notifications:



    <service
android:name="com.johncorser.myapp.services.GcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>


That class is very simple and looks like this:



public class GcmListenerService extends com.google.android.gms.gcm.GcmListenerService {
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d("push", "From: " + from);
Log.d("push", "Message: " + message);
}
}


I would expect these messages to log out after sending the push notifications. But instead nothing happens (no exceptions thrown on the server or app).



Any one see what I'm doing wrong here?



Answers

Why are you using the UUID you generated from the Android Device ID as a registration ID for Google Cloud Messaging?
That's NOT how you get a registration id.



To get a registration ID you have to register with GCM on the device and receive back a registration ID/token, as described in Cloud Messaging for Android Quickstart:



InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);


In order for the above code to work you need to have a google-services.json configuration file (which is parsed by the com.google.gms.google-services gradle plugin, that you also need) in your app/ directory and you need the gcm_defaultSenderId which is the Project ID (Number) you get from the Google Developers Console.



You can easily generate that file and receive the above details by clicking the button "Get a configuration file" and following the steps mentioned there.



The code to get the registration ID needs to be in an IntentService as described here, and you need to define the service in the AndroidManifest.xml file as outlined here

For GCM to be able to communicate with your app, you also need to define in the manifest file a com.google.android.gms.gcm.GcmReceiver which has an intent filter with an action name "com.google.android.c2dm.intent.RECEIVE" and a category name with your package name. Look here for an example.



Answers

Try running the sample here by Google themselves.



https://developers.google.com/cloud-messaging/android/start
https://github.com/googlesamples/google-services/tree/master/android/gcm



I feel like something might just be missing in your manifest file.



Hope that helps.



Answers

In case anyone else runs in to this, the problem was that I did not whitelist my IP address on developers.google.com. I now have it set so all IPs are whitelisted, and it works like a charm.





How to get line break in javascript inside variable

I have an array:



var social = [
["facebook", "#link", "#62b500", "images/facebook.png"],
["instagram", "#link", "#62b500", "images/instagram.png"],
["twitter", "#link", "#62b500", "images/twitter.png"]
];


I want to a add line breaks or space/margin between the icons at certain positions.



The result should look like this:



Facebook
Instagram
----linebreak/free space---
twitter
----linebreak/free space---
something else
something else
something else


My transformation-code so far looks like this:



$("#socialside").append('<ul class="mainul"></ul>');

/// generating bars
for(var i=0;i<social.length;i++){
$(".mainul").append("<li>" + '<ul class="scli" style="background-color:' + social[i][2] + '">' +
'<li>' + social[i][0] + '<img src="' + social[i][3] + '"/></li></ul></li>');
}


What possibilities do I have to add a line-break/space?
How can I achieve this in my JavaScript?



Answers

You can add \n at the end of your items



for (var i = 0; i<social.length;i++){
var para = document.createElement("P");
var t1 = document.createTextNode(social[i]);
para.appendChild(t1);
document.getElementById("lol").appendChild(para);
}


https://jsfiddle.net/wwpj0x0r/10/



Answers

I made it like this one. Will it be good enough?
I will have to create a new loop each time i want a different spacing, but atleast it works for me.



Created a loop that will end on 3 element. Then created the same loop starting from 3 to 4 element and added </br> at the beginning.



for(var i=0;i<3;i++){
$(".mainul").append("<li>" + '<ul class="scli" style="background-color:' + social[i][2] + '">' +
'<li>' + social[i][0] + '<img src="' + social[i][3] + '"/></li></ul></li>');

}


for(var i=3;i<4;i++){
$(".mainul").append("</br><li>" + '<ul class="scli" style="background-color:' + social[i][2] + '">' +
'<li>' + social[i][0] + '<img src="' + social[i][3] + '"/></li></ul></li>');
}


Answers

A <br> or an empty <li></li> would do the job.





Question

My mother died in an accident and my dad is planning to have second marriage.

my dad told me that he will transfer all his property to me legally before second marriage so that property dispute will not occur.

I have question-

Before doing marriage if my father has already transferred all his property to me thn is she still have right to claim my dad property in any way?

Warm regards



Answer

On cursory reading of your question, the answer is NO provided the transfer is by FREE WILL. for detailed discussion, please write to [email protected]
/* */



Answer

Dear client if property is self earned by yr father then he can transfer it to u and his second wife is not entitle for any share. For proper discussion call me on 9422611385 or 8446247807



Adv prasad patil





↑このページのトップヘ