[APP]Anagram (Word Finder) - Open Source - Windows Mobile Apps and Games

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Desktop version is faster than the Mobile version
This is a ported version of my Anagram Desktop version found here.
Using Regular Expression, RE, or RegEx. Though not purely RegEx way .. it has some help of Hashtable and StringBuilder for counting characters (which is MY WAY of counting characters) and appending the words found.
Anyway, at the left .. is the screenshot of the application (click to view larger version). If you noticed, I used “regular expression” as my word.. This is pretty much of a Beta version so.. it might hang your device for sometime (the search is taking too much time)
You can use this app on your scrabble game!
look at the total result.
1,905 words found in 1 minute and 16 seconds and I have total of 192,719 English words in textfile. Am not sure if that’s fast enough .. am using Xperia X1 device. Here’s the specs of this device. Desktop version is much faster. Look here
Download here
How To Use
1. After downloading AnagramMobile.rar and extracting the .exe file in your device. Download english.txt or tagalog.txt.
2. Run the application and tap Open and select english.txt or tagalog.txt file in Open Window.
3. Wait for a few seconds or a minute to load the word list.
4. Enter word, a sentence, or a jumbled letters in “Enter word or sentence here” box
5. and click Find.
6. and wait for the results.
Code Snippet for Finder Class 3.
Fast string concatenation using StringBuilder.
Duplicates problem solved using Hashtable.
Methods
OpenWordDatabaseTextFile(string filename)
Find(string word, string separator, int min)
CountCharacters(string str)
DoRegEx(string pattern, bool UseAllRegexOptionFlag)
string[] Split(string s, string delimeter)
Properties
string TimeDuration
int TotalFound
int TotalWordsFoundInDatabase
PHP:
// Finder Class version 3
// Author: Jayson Ragasa, December 22, 2009
// Copyright© 2009 Jayson Ragasa, Baguio City, Philippines
namespace Anagram
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
public class Finder
{
string _time_duration = string.Empty;
int _ttl_found = 0;
int _ttl_words_in_database = 0;
string new_line_separated_words = string.Empty;
public Finder() { }
public void OpenWordDatabaseTextFile(string filename)
{
using (System.IO.StreamReader reader = new System.IO.StreamReader(filename))
{
new_line_separated_words = reader.ReadToEnd();
}
//_ttl_words_in_database = new_line_separated_words.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Length;
_ttl_words_in_database = Split(new_line_separated_words, "\r\n").Length;
}
public string Find(string word, string separator, int min)
{
string ret = string.Empty;
StringBuilder list = new StringBuilder();
string regex = "^[" + word + " ]+\\r\\n";
DateTime startTime = DateTime.Now;
Hashtable words = new Hashtable();
IDictionaryEnumerator ide;
#region start
{
Regex r = DoRegEx(regex, false);
if (r.IsMatch(new_line_separated_words))
{
Hashtable ht_x;
Hashtable ht_y;
bool notValid = false;
MatchCollection mc = r.Matches(new_line_separated_words);
foreach (Match m in mc)
{
string w = m.Value.Trim();
if (w.Length >= min)
{
ht_x = CountCharacters(m.Value.Trim());
ht_y = CountCharacters(word.Trim());
notValid = false;
ide = ht_x.GetEnumerator();
while (ide.MoveNext())
{
if (Convert.ToInt32(ht_x[ide.Key]) > Convert.ToInt32(ht_y[ide.Key]))
{
notValid = true;
}
}
if (notValid) { continue; }
string thisWord = m.Value.Replace("\r\n", string.Empty);
thisWord = thisWord.Trim();
// don't add the word if the word already exists
// in hashtable
if (!words.ContainsKey(thisWord))
{
words.Add(thisWord, thisWord);
}
}
}
ht_x = null; ht_y = null;
}
}
#endregion
#region build result
{
ide = words.GetEnumerator();
while (ide.MoveNext())
{
list.AppendFormat("{0}" + separator, ide.Value);
}
}
#endregion
DateTime endTime = DateTime.Now;
TimeSpan _duration = endTime - startTime;
ret = list.ToString();
if (ret != string.Empty) ret = ret.Substring(0, ret.Length - separator.Length);
this._time_duration = _duration.ToString();
this._ttl_found = words.Count;
return ret;
}
// Count instance of a character in a string
protected Hashtable CountCharacters(string str)
{
Hashtable ht = new Hashtable();
char[] a_chars = str.ToCharArray();
foreach (char c in a_chars)
{
if (ht.ContainsKey(c))
{
ht[c] = (Convert.ToInt32(ht[c]) + 1).ToString();
}
else
{
ht.Add(c, 1);
}
}
return ht;
}
protected Regex DoRegEx(string pattern, bool UseAllRegexOptionFlag)
{
string regex = pattern;
RegexOptions options;
if (UseAllRegexOptionFlag)
{
options = (((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Singleline) | System.Text.RegularExpressions.RegexOptions.Multiline) | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
}
else
{
options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase);
}
return new Regex(regex, options);
}
protected string[] Split(string s, string delimeter)
{
if (s == null)
throw new ArgumentNullException("stringToBeSplitted is null.");
if (delimeter == null)
throw new ArgumentNullException("delimeter is null.");
int dsum = 0;
int ssum = 0;
int dl = delimeter.Length;
int sl = s.Length;
if (dl == 0 || sl == 0 || sl < dl)
return new string[] { s };
char[] cd = delimeter.ToCharArray();
char[] cs = s.ToCharArray();
List<string> retlist = new List<string>();
for (int i = 0; i < dl; i++)
{
dsum += cd[i];
ssum += cs[i];
}
int start = 0;
for (int i = start; i < sl - dl; i++)
{
if (i >= start && dsum == ssum && s.Substring(i, dl) == delimeter)
{
retlist.Add(s.Substring(start, i - start));
start = i + dl;
}
ssum += cs[i + dl] - cs[i];
}
if (dsum == ssum && s.Substring(sl - dl, dl) == delimeter)
{
retlist.Add(s.Substring(start, sl - dl - start));
retlist.Add("");
}
else
{
retlist.Add(s.Substring(start, sl - start));
}
return retlist.ToArray();
}
public string TimeDuration
{
get { return _time_duration; }
}
public int TotalFound
{
get { return _ttl_found; }
}
public int TotalWordsFoundInDatabase
{
get { return this._ttl_words_in_database; }
}
}
}

Nice work!
Is it possible to have it in french?

Cassatta said:
Nice work!
Is it possible to have it in french?
Click to expand...
Click to collapse
as long as you have a French word list, it'll be fine

nice app. have linked to it from here : 1800PocketPC

the0ne said:
nice app. have linked to it from here : 1800PocketPC
Click to expand...
Click to collapse
thanks so much!

Great app!
Where the hell did you get the Tagalog word list?

harveydent said:
Great app!
Where the hell did you get the Tagalog word list?
Click to expand...
Click to collapse
Well, you can't find it in hell
There's a lot of site providing Tagalog words.. and I put them all together then removed all duplicates and sorted them out using Excel.

Nice App and Nice Title too

Am not getting any notifications from XDA about what's happening on my threads. So if you guys having some problems on my apps and not getting any support from me. Am so sorry.
This post will server as a Wake Up Thread!

Kabayan, thanks for sharing this great app.

darthnol said:
Kabayan, thanks for sharing this great app.
Click to expand...
Click to collapse
uy thanks man. yan ang ginamit ko nuon sa Love Radio kaya na nalo ako ng 3500 pesos. lolz

hi, here's an italian words list
the app works good on PC but on my HD2 crashes each time I try to open a dictionary ,it looks like it does not support a large txt file on WM
could it be fixed?

Great application, I am using now an online website that works as word finder

Thanks for sharing the app and the English word lists! Seems to me like you could improve performance greatly by using a database instead of loading the words directly from the word file. For better speed you could even compile several word files and order words by what letter they are starting with.
Scrabble actually has it's own dictionaries on what words are allowed. To unscramble words I have been using this word search for Scrabble.

Nice app

Nullstring said:
Download here
Click to expand...
Click to collapse
Download is offline. Please reupload

Related

[Q] App Developers:GET contenet from custom Expandablelistview

Hi,
I searched for a part to ask questions abut android programing but cant find so I posted here,I hope I can find my answer
I am new with android programing and I have a problem with expandable list view
I pupulate my data to an expandable list view with SimpleExpandableListAdapter and every thing is good..The only think I want is to findout which Items is selected by user..I searched but Cant fine a working method to do this
here Is my SimpleExpandableListAdapter
Code:
SimpleExpandableListAdapter expListAdapter =
new SimpleExpandableListAdapter(
this,
groupData,
android.R.layout.simple_expandable_list_item_1,
new String[] { "grup"},
new int[] { android.R.id.text1 },
childData,
R.layout.database_list_item,
new String[] { parser.KEY_CatName, parser.KEY_PoetID, parser.KEY_DownloadUrl,parser.KEY_PubDate,parser.KEY_FileSizeInByte,"Status"},
new int[] { R.id.chk_database_list_item,R.id.txt_database_poet_id,R.id.txt_database_download_link,R.id.txt_database_pub_date,R.id.txt_database_size,R.id.txt_database_status }
);
and here Is setOnChildClickListener but It dont do anything
Code:
ExpandList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView arg0, View v, int arg2,
int arg3, long arg4) {
Log.i("setOnChildClickListener", "setOnChildClickListener");
TextView down_link = (TextView) v.findViewById(R.id.txt_database_download_link);
TextView poet_id = (TextView) v.findViewById(R.id.txt_database_poet_id);
String down_linkString;
String poet_idString;
SparseBooleanArray choices = arg0.getCheckedItemPositions();
StringBuilder choicesString = new StringBuilder();
for (int i = 0; i < choices.size(); i++)
{
//added if statement to check for true. The SparseBooleanArray
//seems to maintain the keys for the checked items, but it sets
//the value to false. Adding a boolean check returns the correct result.
//ArrayList<String> Items_for_download = new ArrayList<String>();
if(choices.valueAt(i) == true)
choicesString.append(poet_id.getText().toString()).append(" ");
}
Log.i("selected", choicesString.toString());
return false;
}
});
Thanks for your helps

[TUT][WIP] Custom PlatLogo

It's still in development fase, and it's still beta, it'll show a box cyan-colored, and you can move it by touching it.
File that you need:
apktool
framework.jar
attached .zip file
Step:
BACKUP!
decompile ur framework.jar
put my .smali into /com/android/internal/app/, replace ur PlatLogoActivity.smali with mine.
recompile ur framework.jar, push it to /system/framework/
If you want to see, goto settings>about phone>touch 3x on Android Version quickly
ChangeLogs:
****June, 27
Initial Release
****July, 6
ICS Like anim (far far away from ICS)
Click to expand...
Click to collapse
Video:
www.youtube.com/watch?v=0Rtemjw6hW0
credits:
This forum
Evolution-x4 (i tested my mod on this rom, it may work with all rom)
stackoverflow
Galaxy Y Indonesia
Google
AuliaYF said:
It's still in development fase, and it's still beta, it'll show a box cyan-colored, and you can move it by touching it.
File that you need:
apktool
framework.jar
attached .zip file
Step:
BACKUP!
decompile ur framework.jar
put my .smali into /com/android/internal/app/, replace ur PlatLogoActivity.smali with mine.
recompile ur framework.jar, push it to /system/framework/
If you want to see, goto settings>about phone>touch 3x on Android Version quickly
Screenies:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
credits:
This forum
Evolution-x4 (i tested my mod on this rom, it may work with all rom)
stackoverflow
Galaxy Y Indonesia
Google
Click to expand...
Click to collapse
Please list what all changes you made in the smali file. This is a guide.
Aniruddh Chandratre said:
Please list what all changes you made in the smali file. This is a guide.
Click to expand...
Click to collapse
i have the JAVA code. it's alot. here pastebin*com/YmWcxLz8 replace(*) with (.). i still don't have permission to post link.
sorry man.
Wooooww
@op can u change rectangular shape to a jealybeen
Can someone try this and report? I am feeling tired after coming back home. Here.. try this :
Code:
package com.android.internal.app;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class PlatLogoActivity extends Activity {
Toast mToast;
ImageView mContent;
int mCount;
final Handler mHandler = new Handler();
private View makeView() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
LinearLayout view = new LinearLayout(this);
view.setOrientation(LinearLayout.VERTICAL);
view.setLayoutParams(
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
final int p = (int)(8 * metrics.density);
view.setPadding(p, p, p, p);
Typeface light = Typeface.create("sans-serif-light", Typeface.NORMAL);
Typeface normal = Typeface.create("sans-serif", Typeface.BOLD);
final float size = 14 * metrics.density;
final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
lp.bottomMargin = (int) (-4*metrics.density);
TextView tv = new TextView(this);
if (light != null) tv.setTypeface(light);
tv.setTextSize(1.25f*size);
tv.setTextColor(0xFFFFFFFF);
tv.setShadowLayer(4*metrics.density, 0, 2*metrics.density, 0x66000000);
tv.setText("Android " + Build.VERSION.RELEASE);
view.addView(tv, lp);
tv = new TextView(this);
if (normal != null) tv.setTypeface(normal);
tv.setTextSize(size);
tv.setTextColor(0xFFFFFFFF);
tv.setShadowLayer(4*metrics.density, 0, 2*metrics.density, 0x66000000);
tv.setText("JELLY BEAN");
view.addView(tv, lp);
return view;
}
@[URL="http://forum.xda-developers.com/member.php?u=439709"]override[/URL]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mToast = Toast.makeText(this, "", Toast.LENGTH_LONG);
mToast.setView(makeView());
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
mContent = new ImageView(this);
mContent.setImageResource(com.android.internal.R.drawable.platlogo_alt);
mContent.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
final int p = (int)(32 * metrics.density);
mContent.setPadding(p, p, p, p);
mContent.setOnClickListener(new View.OnClickListener() {
@[URL="http://forum.xda-developers.com/member.php?u=439709"]override[/URL]
public void onClick(View v) {
mToast.show();
mContent.setImageResource(com.android.internal.R.drawable.platlogo);
}
});
mContent.setOnLongClickListener(new View.OnLongClickListener() {
@[URL="http://forum.xda-developers.com/member.php?u=439709"]override[/URL]
public boolean onLongClick(View v) {
try {
startActivity(new Intent(Intent.ACTION_MAIN)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
.addCategory("com.android.internal.category.PLATLOGO"));
//.setClassName("com.android.systemui","com.android.systemui.BeanBag"));
} catch (ActivityNotFoundException ex) {
android.util.Log.e("PlatLogoActivity", "Couldn't find a bag of beans.");
}
finish();
return true;
}
});
setContentView(mContent);
}
}
and here is the com.android.systemui.BeanBag code. The java file to be taken.
Code:
package com.android.systemui;
import android.animation.AnimatorSet;
import android.animation.PropertyValuesHolder;
import android.animation.ObjectAnimator;
import android.animation.TimeAnimator;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import java.util.HashMap;
import java.util.Random;
public class BeanBag extends Activity {
final static boolean DEBUG = false;
public static class Board extends FrameLayout
{
static Random sRNG = new Random();
static float lerp(float a, float b, float f) {
return (b-a)*f + a;
}
static float randfrange(float a, float b) {
return lerp(a, b, sRNG.nextFloat());
}
static int randsign() {
return sRNG.nextBoolean() ? 1 : -1;
}
static boolean flip() {
return sRNG.nextBoolean();
}
static float mag(float x, float y) {
return (float) Math.sqrt(x*x+y*y);
}
static float clamp(float x, float a, float b) {
return ((x<a)?a:((x>b)?b:x));
}
static float dot(float x1, float y1, float x2, float y2) {
return x1*x2+y1+y2;
}
static <E> E pick(E[] array) {
if (array.length == 0) return null;
return array[sRNG.nextInt(array.length)];
}
static int pickInt(int[] array) {
if (array.length == 0) return 0;
return array[sRNG.nextInt(array.length)];
}
static int NUM_BEANS = 40;
static float MIN_SCALE = 0.2f;
static float MAX_SCALE = 1f;
static float LUCKY = 0.001f;
static int MAX_RADIUS = (int)(576 * MAX_SCALE);
static int BEANS[] = {
R.drawable.redbean0,
R.drawable.redbean0,
R.drawable.redbean0,
R.drawable.redbean0,
R.drawable.redbean1,
R.drawable.redbean1,
R.drawable.redbean2,
R.drawable.redbean2,
R.drawable.redbeandroid,
};
static int COLORS[] = {
0xFF00CC00,
0xFFCC0000,
0xFF0000CC,
0xFFFFFF00,
0xFFFF8000,
0xFF00CCFF,
0xFFFF0080,
0xFF8000FF,
0xFFFF8080,
0xFF8080FF,
0xFFB0C0D0,
0xFFDDDDDD,
0xFF333333,
};
public class Bean extends ImageView {
public static final float VMAX = 1000.0f;
public static final float VMIN = 100.0f;
public float x, y, a;
public float va;
public float vx, vy;
public float r;
public float z;
public int h,w;
public boolean grabbed;
public float grabx, graby;
public long grabtime;
private float grabx_offset, graby_offset;
public Bean(Context context, AttributeSet as) {
super(context, as);
}
public String toString() {
return String.format("<bean (%.1f, %.1f) (%d x %d)>",
getX(), getY(), getWidth(), getHeight());
}
private void pickBean() {
int beanId = pickInt(BEANS);
if (randfrange(0,1) <= LUCKY) {
beanId = R.drawable.jandycane;
}
BitmapDrawable bean = (BitmapDrawable) getContext().getResources().getDrawable(beanId);
Bitmap beanBits = bean.getBitmap();
h=beanBits.getHeight();
w=beanBits.getWidth();
if (DEBUG) {
bean.setAlpha(0x80);
}
this.setImageDrawable(bean);
Paint pt = new Paint();
final int color = pickInt(COLORS);
ColorMatrix CM = new ColorMatrix();
float[] M = CM.getArray();
// we assume the color information is in the red channel
/* R */ M[0] = (float)((color & 0x00FF0000) >> 16) / 0xFF;
/* G */ M[5] = (float)((color & 0x0000FF00) >> 8) / 0xFF;
/* B */ M[10] = (float)((color & 0x000000FF)) / 0xFF;
pt.setColorFilter(new ColorMatrixColorFilter(M));
setLayerType(View.LAYER_TYPE_HARDWARE, (beanId == R.drawable.jandycane) ? null : pt);
}
public void reset() {
pickBean();
final float scale = lerp(MIN_SCALE,MAX_SCALE,z);
setScaleX(scale); setScaleY(scale);
r = 0.3f*Math.max(h,w)*scale;
a=(randfrange(0,360));
va = randfrange(-30,30);
vx = randfrange(-40,40) * z;
vy = randfrange(-40,40) * z;
final float boardh = boardHeight;
final float boardw = boardWidth;
//android.util.Log.d("BeanBag", "reset: w="+w+" h="+h);
if (flip()) {
x=(vx < 0 ? boardw+2*r : -r*4f);
y=(randfrange(0, boardh-3*r)*0.5f + ((vy < 0)?boardh*0.5f:0));
} else {
y=(vy < 0 ? boardh+2*r : -r*4f);
x=(randfrange(0, boardw-3*r)*0.5f + ((vx < 0)?boardw*0.5f:0));
}
}
public void update(float dt) {
if (grabbed) {
// final float interval = (SystemClock.uptimeMillis() - grabtime) / 1000f;
vx = (vx * 0.75f) + ((grabx - x) / dt) * 0.25f;
x = grabx;
vy = (vy * 0.75f) + ((graby - y) / dt) * 0.25f;;
y = graby;
} else {
x = (x + vx * dt);
y = (y + vy * dt);
a = (a + va * dt);
}
}
public float overlap(Bean other) {
final float dx = (x - other.x);
final float dy = (y - other.y);
return mag(dx, dy) - r - other.r;
}
[user=439709]@override[/user]
public boolean onTouchEvent(MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
grabbed = true;
grabx_offset = e.getRawX() - x;
graby_offset = e.getRawY() - y;
va = 0;
// fall
case MotionEvent.ACTION_MOVE:
grabx = e.getRawX() - grabx_offset;
graby = e.getRawY() - graby_offset;
grabtime = e.getEventTime();
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
grabbed = false;
float a = randsign() * clamp(mag(vx, vy) * 0.33f, 0, 1080f);
va = randfrange(a*0.5f, a);
break;
}
return true;
}
}
TimeAnimator mAnim;
private int boardWidth;
private int boardHeight;
public Board(Context context, AttributeSet as) {
super(context, as);
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
setWillNotDraw(!DEBUG);
}
private void reset() {
// android.util.Log.d("Nyandroid", "board reset");
removeAllViews();
final ViewGroup.LayoutParams wrap = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
for(int i=0; i<NUM_BEANS; i++) {
Bean nv = new Bean(getContext(), null);
addView(nv, wrap);
nv.z = ((float)i/NUM_BEANS);
nv.z *= nv.z;
nv.reset();
nv.x = (randfrange(0, boardWidth));
nv.y = (randfrange(0, boardHeight));
}
if (mAnim != null) {
mAnim.cancel();
}
mAnim = new TimeAnimator();
mAnim.setTimeListener(new TimeAnimator.TimeListener() {
private long lastPrint = 0;
public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
if (DEBUG && totalTime - lastPrint > 5000) {
lastPrint = totalTime;
for (int i=0; i<getChildCount(); i++) {
android.util.Log.d("BeanBag", "bean " + i + ": " + getChildAt(i));
}
}
for (int i=0; i<getChildCount(); i++) {
View v = getChildAt(i);
if (!(v instanceof Bean)) continue;
Bean nv = (Bean) v;
nv.update(deltaTime / 1000f);
for (int j=i+1; j<getChildCount(); j++) {
View v2 = getChildAt(j);
if (!(v2 instanceof Bean)) continue;
Bean nv2 = (Bean) v2;
final float overlap = nv.overlap(nv2);
}
nv.setRotation(nv.a);
nv.setX(nv.x-nv.getPivotX());
nv.setY(nv.y-nv.getPivotY());
if ( nv.x < - MAX_RADIUS
|| nv.x > boardWidth + MAX_RADIUS
|| nv.y < -MAX_RADIUS
|| nv.y > boardHeight + MAX_RADIUS)
{
nv.reset();
}
}
if (DEBUG) invalidate();
}
});
}
[user=439709]@override[/user]
protected void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w,h,oldw,oldh);
boardWidth = w;
boardHeight = h;
// android.util.Log.d("Nyandroid", "resized: " + w + "x" + h);
}
public void startAnimation() {
stopAnimation();
if (mAnim == null) {
post(new Runnable() { public void run() {
reset();
startAnimation();
} });
} else {
mAnim.start();
}
}
public void stopAnimation() {
if (mAnim != null) mAnim.cancel();
}
[user=439709]@override[/user]
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
stopAnimation();
}
[user=439709]@override[/user]
public boolean isOpaque() {
return false;
}
[user=439709]@override[/user]
public void onDraw(Canvas c) {
if (DEBUG) {
//android.util.Log.d("BeanBag", "onDraw");
Paint pt = new Paint();
pt.setAntiAlias(true);
pt.setStyle(Paint.Style.STROKE);
pt.setColor(0xFFFF0000);
pt.setStrokeWidth(4.0f);
c.drawRect(0, 0, getWidth(), getHeight(), pt);
pt.setColor(0xFFFFCC00);
pt.setStrokeWidth(1.0f);
for (int i=0; i<getChildCount(); i++) {
Bean b = (Bean) getChildAt(i);
final float a = (360-b.a)/180f*3.14159f;
final float tx = b.getTranslationX();
final float ty = b.getTranslationY();
c.drawCircle(b.x, b.y, b.r, pt);
c.drawCircle(tx, ty, 4, pt);
c.drawLine(b.x, b.y, (float)(b.x+b.r*Math.sin(a)), (float)(b.y+b.r*Math.cos(a)), pt);
}
}
}
}
private Board mBoard;
[user=439709]@override[/user]
public void onStart() {
super.onStart();
// ACHIEVEMENT UNLOCKED
PackageManager pm = getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(this, BeanBagDream.class),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
);
mBoard = new Board(this, null);
setContentView(mBoard);
}
[user=439709]@override[/user]
public void onPause() {
super.onPause();
mBoard.stopAnimation();
}
[user=439709]@override[/user]
public void onResume() {
super.onResume();
mBoard.startAnimation();
}
}
For making the platlogo like jellybean you can take help of android platform_frameworks_base available on Github. here is the github link : https://github.com/android/platform_frameworks_base . Have a good day and work efficiently. I see a new dev coming up
i can't use the beanbag man, i tried, because it's using API17, GB usinf API10.
i've done making StatusBarBrightness controller, tomorrow i'll share.
Thanxx its working:thumbup::thumbup:
Awesome
It loookk mor kooll if u chage blue box to a jeally bean if possible
Omkar$ said:
Thanxx its working:thumbup::thumbup:
Awesome
It loookk mor kooll if u chage blue box to a jeally bean if possible
Click to expand...
Click to collapse
i'll do my best to make it possible.
Delete
xXx~~~SHLOK~~~xXx said:
There is a thing called spoiler , you should use it so that people dont have to scroll pages to see what they are not interested in.
Click to expand...
Click to collapse
Dude.. I have used the hide-hide tags in that post. If you can't see that you dont have to scroll then please check with an eye doctor nearby.
Aniruddh Chandratre said:
Dude.. I have used the hide-hide tags in that post. If you can't see that you dont have to scroll then please check with an eye doctor nearby.
Click to expand...
Click to collapse
Sorry man i was browsing with tapatalk , couldnt see them.
I think [Beta] and [WIP] give the same meaning, Right ?
Aniruddh Chandratre said:
Please list what all changes you made in the smali file. This is a guide.
Click to expand...
Click to collapse
Yes , coz there is always time to quote the whole op
Sent from my Galaxy Note II using xda app-developers app
Reynaldi said:
Yes , coz there is always time to quote the whole op
Sent from my Galaxy Note II using xda app-developers app
Click to expand...
Click to collapse
not deodex frameworks.jar

[Q] :How to use list view for Map

Hi,
I am developing an android app in which i am using csv file and displaying column contents as listview its displaying as [a,b,c,d] in single row how to display them in individual row in listview.Please any one help me how to achive this.
This is my csv file reading code using hashcode.
Code:
public static Map<String,ArrayList<String>> parseCsv(InputStreamReader reader, String separator, boolean hasHeader) throws IOException {
Map<String,ArrayList<String> > values = new LinkedHashMap<String,ArrayList<String>>();
List<String> columnNames = new LinkedList<String>();
BufferedReader br = null;
br = new BufferedReader(reader);
String line;
int numLines = 0;
while ((line = br.readLine()) != null) {
//if (StringUtils.isNotBlank(line)) {
//if (!line.startsWith("#")) {
String[] tokens = line.split(separator);
if (tokens != null) {
for (int i = 0; i < tokens.length; ++i) {
if (numLines == 0) {
columnNames.add(hasHeader ? tokens[i] : ("row_"+i));
} else {
ArrayList<String> column = values.get(columnNames.get(i));
if (column == null) {
column = new ArrayList<String>();
}
column.add(tokens[i]);
values.put(columnNames.get(i), column);
}
}
}
++numLines;
}
// }//
// }//
return values;
listview code is:
Code:
oslist.add(values);
ListView list = (ListView) findViewById(R.id.studentnames);
String name="name";
// Add it listview
ListAdapter adapter = new SimpleAdapter(this,
oslist, R.layout.student_list, new String[] { name }, new int[] { R.id.name});
list.setAdapter(adapter);

How to support icons in FileDialog

So i found this perfect code to be able to select zip from sd, but the list looks so basic and I would like to add icons (like one common icon for all dirs), however it seems too hard to do on my own, here is the code:
Code:
private void loadFileList(File path) {
this.currentPath = path;
List<String> r = new ArrayList<String>();
if (path.exists()) {
if (path.getParentFile() != null) r.add(PARENT_DIR);
FilenameFilter filter = new FilenameFilter() {
@SuppressLint("DefaultLocale")
public boolean accept(File dir, String filename) {
File sel = new File(dir, filename);
if (!sel.canRead()) return false;
if (selectDirectoryOption) return sel.isDirectory();
else {
boolean endsWith = fileEndsWith != null ? filename.toLowerCase().endsWith(fileEndsWith) : true;
return endsWith || sel.isDirectory();
}
}
};
String[] fileList1 = path.list(filter);
for (String file : fileList1) {
r.add(file);
}
}
fileList = (String[]) r.toArray(new String[]{});
}

Expert: BestPal (Chatting) application using Huawei CloudDB, Auth service, Cloud Function and Push Kit

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Introduction
In this article, we can learn that chat option between two people, they can share text between each other. The application needs to have instant messaging so once a user sends the message to a friend over the application, the friend will receive the push notification at the given time. The quintessence of an app like instant application is available and react to ongoing actions. Also, push notifications can be an excellent promotional tool that can be used to inform users about updates and new functionalities.
Huawei Kits Used​
Huawei Cloud DB
Huawei Auth Service
Huawei Cloud function.
Huawei Push Kit
Huawei API Used​
Huawei CloudDB API - Cloud DB is used to store users data, users chat and also used to manage users chat history with other users.
a) Upsert
i) Insert data of the users from the profile.
ii) Create and insert room id, room id is consider as a reference between two users chat. Using room id will store all the respective chat data in the DB.
iii) Insert Chat data between two users based on the room id.
b) Query
i) Get list of Contacts for chat.
ii) Get list of users with whom logged in user chatted before.
ii) Get details of the chat screen with all the chat messages which includes images, text and location.
Huawei Auth Service – Using the Auth Service we are registering the user on the Ecosystem. We are using the Phone number auth service for the same to receive the OTP and verify the user here.
Huawei Cloud function – We are triggering the Huawei Push notification system using cloud function for the same.
Huawei Push kit - Push kit is used to push notification of message to other user. So when one user send message it will notify other user through push notification only.
Used the rest end point for the cloud function to send the push notification once the message is end, trigger from the device.
On HMSMessage Received This is once parsing the data as per our need on the implementation, so we need to parse image and location when shared by other success.
Database structure​
Now it's time to create project on Huawei console and development​Integration Preparations​You must complete the following preparations:
Register as a developer on Huawei console.
Create a project and an app in AppGallery Connect.
Generate and configure the signing certificate fingerprint.
Enable Auth service, Push and Cloud DB.
For details, refer to Configuring App Information in AppGallery Connect for HMS
First create cloud DB Zones
Create 3 object types
ChatRoomId: contain all chatting room id.
User: all register user details.
UserChat: all users chat details.
Let's start development with Login Page
We will login with Phone number using HMS Auth service.
Enable Phone number Authentication mode as shown in below image.
Add dependency
XML:
// HMS dependencies
implementation "com.huawei.agconnect:agconnect-database:$rootProject.ext.agdatabase"
implementation "com.huawei.agconnect:agconnect-auth:$rootProject.ext.agauth"
implementation "com.huawei.hms:push:$rootProject.ext.pushkit"
Enter the valid phone number, we will get OTP on same number using below method.
GET OTP
Java:
VerifyCodeSettings settings = new VerifyCodeSettings.Builder()
.action(VerifyCodeSettings.ACTION_REGISTER_LOGIN)
.sendInterval(30)
.locale(Locale.getDefault())
.build();
Task<VerifyCodeResult> task = AGConnectAuth.getInstance().requestVerifyCode(countryCodeStr, phoneNumberStr, settings);
task.addOnSuccessListener(TaskExecutors.immediate(), verifyCodeResult -> {
if (null != verifyCodeResult) {
verifyCodeResultMutableLiveData.postValue(verifyCodeResult);
}
});
task.addOnFailureListener(e ->
AppLog.logE(TAG, "onFailure: " + e.getCause()));
Verify Contact details
Java:
PhoneUser phoneUser = new PhoneUser.Builder()
.setCountryCode(countryCodeStr)
.setPhoneNumber(phoneNumberStr)
.setVerifyCode(code)
.build();
AGConnectAuth.getInstance().createUser(phoneUser)
.addOnSuccessListener(signInResult -> {
if (signInResult != null) {
User user = new User();
user.setUsername(signInResult.getUser().getDisplayName());
user.setPhoneNumber(phoneNumberStr);
userMutableLiveData.postValue(user);
}
})
.addOnFailureListener(e -> {
Log.e(TAG, "verifyContactDetails: " + e.getStackTrace());
User user = new User();
user.setPhoneNumber(phoneNumberStr);
userMutableLiveData.setValue(user);
});
After verify, user can authenticate successfully.
Now we have to complete the user profile, as in below picture you can see we have only phone number.
Create/ Update profile
Java:
public void saveUser(User user, Context context) {
CloudDBHelper.getInstance().openDb((isConnected, cloudDBZone) -> {
if (isConnected && cloudDBZone != null) {
if (cloudDBZone == null) {
return;
} else {
Task<Integer> insertTask = cloudDBZone.executeUpsert(user);
insertTask.addOnSuccessListener(integer -> {
userMutableLiveData.setValue(true);
CloudDBHelper.getInstance().closeDb(context);
}).addOnFailureListener(e -> {
userMutableLiveData.setValue(false);
CloudDBHelper.getInstance().closeDb(context);
});
}
}
});
}
Generate push token
Java:
GetToken getToken = new GetToken(app_id, UserProfileActivity.this);
getToken.setGetTokenListener(this);
getToken.execute();
GetToken class is a service class to generate push token
Java:
public class GetToken extends AsyncTask<Void, Void, String> {
private static final String TAG = GetToken.class.getSimpleName();
private Context context;
private String appId;
private GetTokenListener getTokenListener;
public GetToken(String appId, Context context) {
this.appId = appId;
this.context = context;
}
public void setGetTokenListener(GetTokenListener getTokenListener) {
this.getTokenListener = getTokenListener;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(Void... voids) {
try {
String pushToken = HmsInstanceId.getInstance(context).getToken(appId, HmsMessaging.DEFAULT_TOKEN_SCOPE);
AppLog.logD(TAG, pushToken);
getTokenListener.getToken(pushToken);
return pushToken;
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
}
}
It will create the user profile and update data into Cloud DB.
Start chat for first time
We have to create room id for chatting between two people.
Java:
public void callCreateRoomId(final String userMobileTo, final String userMobileFrom) {
CloudDBHelper.getInstance().openDb(new OnDBZoneOpen() {
@Override
public void isDBZoneOpen(boolean isConnected, CloudDBZone cloudDBZone) {
if (cloudDBZone != null) {
ChatRoomId roomId = new ChatRoomId();
mRoomDataIndex = mRoomDataIndex + 1;
AppLog.logE(TAG, "New ROOM IS WILL BE ===> " + mRoomDataIndex);
roomId.setRoom_id(String.valueOf(mRoomDataIndex));
roomId.setUser_mobile_to(userMobileTo);
roomId.setUser_mobile_from(userMobileFrom);
roomId.setUpdate_shadow_flag(true);
Task<Integer> insertTask = cloudDBZone.executeUpsert(roomId);
insertTask.addOnSuccessListener(insertSuccessListener(roomId))
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
AppLog.logE(TAG, "Exception in creating room id " + e.getLocalizedMessage());
}
}).addOnCanceledListener(new OnCanceledListener() {
@Override
public void onCanceled() {
AppLog.logE(TAG, "Inside on cancel listener");
}
});
} else {
if (mOnApiError != null) {
mOnApiError.onError("Cloud database zone is null", new Throwable("CloudDBZone is null"));
}
}
}
});
}
Get previous chats from cloudDB
Java:
public void getUserChatByRoomID(String roomId, Context context) {
CloudDBZoneQuery<UserChat> query = CloudDBZoneQuery.where(UserChat.class).equalTo(DBConstants.roomId, roomId).orderByAsc(DBConstants.MESSAGE_TIMESTAMP);
getUserChat(query, context);
}
private void getUserChat(CloudDBZoneQuery<UserChat> userQuery, Context context) {
CloudDBHelper.getInstance().openDb((isConnected, cloudDBZone) -> {
Task<CloudDBZoneSnapshot<UserChat>> queryTask = cloudDBZone.executeQuery(userQuery,
CloudDBZoneQuery.CloudDBZoneQueryPolicy.POLICY_QUERY_FROM_CLOUD_ONLY);
queryTask.addOnSuccessListener(userChatCloudDBZoneSnapshot -> {
processSnapShot(userChatCloudDBZoneSnapshot.getSnapshotObjects(), context);
});
});
}
private void processSnapShot(CloudDBZoneObjectList<UserChat> userCloudDBZoneSnapshot, Context context) {
if (userCloudDBZoneSnapshot != null) {
ArrayList<UserChat> users = new ArrayList<>();
while (userCloudDBZoneSnapshot.hasNext()) {
UserChat user = null;
try {
user = userCloudDBZoneSnapshot.next();
users.add(user);
} catch (AGConnectCloudDBException e) {
e.printStackTrace();
CloudDBHelper.getInstance().closeDb(context);
}
}
userChatMutableLiveData.setValue(users);
CloudDBHelper.getInstance().closeDb(context);
}
}
Start Sending chat messages
messageType: user can send message in text, image, location or in video Types.
Java:
private void setMessage(String messageType) {
Util.showProgressBar(MessageActivity.this);
UserChat userChat = new UserChat();
userChat.setRoom_id(roomId);
userChat.setMessage_timestamp(Long.parseLong(Util.getTimeStamp()));
userChat.setChat_id(Util.getRandomNumber());
userChat.setReceiver_name(receiverText);
userChat.setReceiver_phone(receiverPhoneNumber);
userChat.setSender_name(ChitChatSharedPref.getInstance().getString(Constants.USER_NAME, ""));
userChat.setSender_phone(ChitChatSharedPref.getInstance().getString(Constants.PHONE_NUMBER, ""));
userChat.setMessage_type(messageType);
switch (messageType) {
case Constants.MESSAGE_TYPE_TEXT:
userChat.setMessage_data(textSend.getText().toString());
messageViewModel.saveUserChat(userChat);
messageViewModel.userUpdatedSuccessfully.observe(MessageActivity.this, aBoolean -> {
if (aBoolean) {
Util.stopProgressBar();
getChatList();
} else {
Util.stopProgressBar();
}
});
break;
}
messageViewModel.queryForToken(receiverPhoneNumber, MessageActivity.this);
}
It will save user data into cloud dB
Java:
public void saveUserChat(UserChat userChat) {
CloudDBHelper.getInstance().openDb((isConnected, cloudDBZone) -> {
if (cloudDBZone != null) {
Task<Integer> insertTask = cloudDBZone.executeUpsert(userChat);
insertTask
.addOnSuccessListener(integer ->
userUpdatedSuccessfully.setValue(true))
.addOnFailureListener(e -> {
userUpdatedSuccessfully.setValue(false);
AppLog.logE(TAG, e.getMessage());
});
} else {
userUpdatedSuccessfully.setValue(false);
}
});
}
It's time to send push notification
Java:
public void queryForToken(String phoneNumber, Context context) {
CloudDBZoneQuery<User> query = CloudDBZoneQuery.where(User.class).equalTo(DBConstants.userNumber, phoneNumber);
processNumberCheck(query, context);
}
messageViewModel.tokenMutableLiveData.observe(MessageActivity.this, s -> {
PushApis pushApis = new PushApis(MessageActivity.this);
if (messageType.equalsIgnoreCase(Constants.MESSAGE_TYPE_TEXT)) {
pushApis.sendPushNotification(roomId, messageType, "104739093", MessageActivity.this.textSend.getText().toString(), s);
textSend.setText("");
}
});
Setting up push messaging API's
Java:
public class PushApis {
private Context context;
public PushApis(Context context) {
this.context = context;
}
public void sendPushNotification(String chatId, String message, String appId, String messageData, String userPushTokens) {
try {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String response = "";
URL url = new URL(Constants.TOKEN_URL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("POST", "/oauth2/v3/token HTTP/1.1");
connection.setRequestProperty("Host", "oauth-login.cloud.huawei.com");
HashMap<String, String> params = new HashMap<>();
params.put("grant_type", "client_credentials");
params.put("client_secret", Constants.CLIENT_SECRET);
params.put("client_id", Constants.CLIENT_ID);
String postDataLength = getDataString(params);
OutputStream os = connection.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
writer.write(postDataLength);
writer.flush();
writer.close();
os.close();
int responseCode = connection.getResponseCode();
if (responseCode == HttpsURLConnection.HTTP_OK) {
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((line = br.readLine()) != null) {
response += line;
}
} else {
response = "";
}
AppLog.logE("Response", response);
Gson gson = new Gson();
BearerRequest bearerRequest = gson.fromJson(response, BearerRequest.class);
triggerPush(bearerRequest.getAccess_token(), appId, chatId, message, messageData, userPushTokens);
} catch (Exception e) {
e.printStackTrace();
}
}
private String getDataString(HashMap<String, String> params) throws UnsupportedEncodingException {
StringBuilder result = new StringBuilder();
boolean first = true;
for (Map.Entry<String, String> entry : params.entrySet()) {
if (first)
first = false;
else
result.append("&");
result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
}
return result.toString();
}
private void triggerPush(String bearer, String appId, String chatId, String messageType, String messageData, String userPushTokens) {
try {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String response = null;
URL url = new URL("https://push-api.cloud.huawei.com/v1/" + appId + "/messages:send");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Authorization", "Bearer " + bearer);
connection.setRequestProperty("Host", "oauth-login.cloud.huawei.com");
connection.setRequestProperty("POST", "/oauth2/v2/token HTTP/1.1");
OutputStream os = connection.getOutputStream();
Data data = new Data();
data.message = messageType;
data.roomId = chatId;
data.messageData = messageData;
data.sender_name = senderName;
data.sender_phone = senderPhone;
data.title = context.getResources().getString(R.string.app_name);
ArrayList<String> token = new ArrayList<>();
token.add(userPushTokens);
Message message = new Message();
message.tokens = token;
message.data = data.toString();
PushMessageRequest pushMessageRequest = new PushMessageRequest();
pushMessageRequest.message = message;
pushMessageRequest.validate_only = false;
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
Gson gson = new Gson();
JSONObject jsonObject = new JSONObject(gson.toJson(pushMessageRequest, PushMessageRequest.class));
writer.write(jsonObject.toString());
writer.flush();
writer.close();
os.close();
int responseCode = connection.getResponseCode();
String line = null;
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((line = br.readLine()) != null) {
response += line;
}
AppLog.logE("Response", response);
} catch (Exception e) {
e.getStackTrace();
}
}
}
Conclusion
In this article, we have learned how we can create a simple messaging application with cloud dB, auth service and push kit. We can also use cloud storage for store profile picture, location, documents or audio and video files.
Thanks for reading this article. Be sure to like and comment to this article, if you found it helpful. It means a lot to me.
Reference
https://developer.huawei.com/consumer/en/agconnect/cloud-base/
https://developer.huawei.com/consum...-Guides/service-introduction-0000001050040060
https://developer.huawei.com/consumer/en/agconnect/auth-service/

Categories

Resources