String varients[][]={
{"A","B","C"},
{"S","U","N"},
{"R","G","B"},
{"30","35","37"}
};
int totCombination=1;
for(int i = 0; i < varients.length; i++)
{
totCombination=totCombination * varients[i].length;
}
try {
String outStr = "";
for (int cat = 0; cat < totCombination; cat++) {
int looptotal = totCombination;
outStr=outStr+cat+"===>";
for (int item = 0; item < varients.length; item++) {
int part = looptotal / varients[item].length;
looptotal = part;//totCombination/part
int selItem = (cat / (looptotal))%varients[item].length;
outStr = outStr + (item==0?"":",")+ varients[item][selItem];
}
outStr = outStr + "\n";
}
Log.i("Item", "" + outStr);
}catch (Exception ex)
{
Log.i("Item", "" + ex.toString());
}
Android
Friday, 10 June 2016
cartesian , inter cross combinations
Labels:
Array cross multiplication,
cartesian,
cross join
Location:
Surat, Gujarat, India
Wednesday, 25 May 2016
GCM PushNotification in android
It's Simple
Let's go for GCM In Android
just follow following step and you get GCM notification easily
Step 1:- Add Following Dependency
compile 'com.google.android.gms:play-services:8.1.0'
Step 2:- Android Manifiest.xml
Permission:-
<permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.example.googlemaps.permission.MAPS_RECEIVE" /> <uses-permission android:name="android.permission.GET_TASKS" />
Receiver
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>Service<service android:name="${applicationId}.PushNotification" android:exported="false"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service>Step 3:- download 2 files and put in your codeGCMClientManager.javahttps://drive.google.com/open?id=0B1dF4YSBqUoobVlGWlZ5dXFmbVEPushNotification.javahttps://drive.google.com/open?id=0B1dF4YSBqUooTmZSRjNDcE1rQkEStep 4:- register Notificationcall it in your first page or login page and save notification tokenprivate void registerNotification() { GCMClientManager pushClientManager = new GCMClientManager(this, your project no); pushClientManager.registerIfNeeded(new GCMClientManager.RegistrationCompletedHandler() { @Override public void onSuccess(String registrationId, boolean isNewRegistration) { Log.d("Registration id",registrationId);//eTtH4OOYfm8:APA91bG3FEjoR0gGfs78dvyA-1DFxlDSlf7F8DrN1vJjnvyGBi6ZbdwGcqAeu2piQ15YQWDNwdXILK-lQHMBKrkwYg2KOSEkW6QSDKTlQbZyOLst7vDXYCXsJL4unN4h2WYGJJeOjbtz } @Override public void onFailure(String ex) { Log.i("error-->>",""+ex); super.onFailure(ex); } }); }
Thursday, 5 May 2016
Work With AQuery in android
Today I Show You How To Work With AQuery
- Startup
- Get Method
- Post Method
- Image Loading
- Startup :-
compile Gson and Aquery library :-
compile 'com.google.code.gson:gson:2.2.4'
put this file to "libs" folder
https://drive.google.com/open?id=0B1dF4YSBqUooNWZPX0pVXzFtLXc
give 2 permission:-
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- Get Method
public void asyncJson()
{
String url = "http://www.your web service url";aq.ajax(url, JSONObject.class, new AjaxCallback<JSONObject>() { @Override public void callback(String url, JSONObject json, AjaxStatus status) { if(json != null){Jsonresult jsonResult = new Jsonresult();JsonElement json2 = new JsonParser().parse(json.toString());Type type = new TypeToken<Jsonresult>() {}.getType();jsonResult = new Gson().fromJson(json2,type);Toast.makeText(aq.getContext(), status.getCode() + ":" + json.toString(), Toast.LENGTH_LONG).show();}else{ //ajax error, show error code Toast.makeText(aq.getContext(), "Error:" + status.getCode(), Toast.LENGTH_LONG).show(); } } });}
- Post Method
public void AqueryPost() { JSONObject obj = new JSONObject(); try { obj.put("UserPassword", "123456"); obj.put("UserName", "user"); Log.i("json", obj.toString()); } catch (Exception e) { return; } final AQuery aq = new AQuery(signup); aq.post("your URL", obj, JSONObject.class, new AjaxCallback<JSONObject>() { @Override public void callback(String url, JSONObject json, AjaxStatus status) { ConstantData.progressclose(signup); if (json != null) { try { Jsonresult jsonResult = new Jsonresult(); JsonElement json2 = new JsonParser() .parse(json.toString()); Type type = new TypeToken<Jsonresult>() { }.getType(); jsonResult = new Gson().fromJson(json2, type); // if (jsonResult.isFlag()) { if (jsonResult.getMessage().equalsIgnoreCase("success")) { } else
Toast.makeText(signup, jsonResult.getMessage(), Toast.LENGTH_LONG).show(); } catch (Exception ex) { Toast.makeText(aq.getContext(), "Error :" + json.toString(), Toast.LENGTH_LONG).show(); } } else { ConstantData.progressclose(signup); //ajax error, show error code
Toast.makeText(aq.getContext(), "Error:" + status.getCode(), Toast.LENGTH_LONG).show(); } } }); }
- Image Loading
public static void SetImage(ImageView imageView) { AQuery aq = new AQuery(MainActivity.this); AjaxCallback.setNetworkLimit(15); BitmapAjaxCallback.setIconCacheLimit(50); BitmapAjaxCallback.setCacheLimit(50);
String urlll = "Your Pic URL";
aq.id(imageView).image(urlll, false, true, 0, R.drawable.background, null, AQuery.FADE_IN); }
Subscribe to:
Comments (Atom)