[DEV] Adding your ROM to ROM Manager - Galaxy S I9000 General

It's easy, it's free. And here's how you do it!
You will need to create two simple JavaScript files:
A file that describes your ROMs that you send to me.
A file that you host that lists your ROMs, so you can update your ROM Manager section.
First, your developer/ROM description file:
Code:
{
// This is what name you want your ROMs to show up under.
developer: "CyanogenMod",
// Your id. This should have no spaces or other funny characters.
// This would ideally be your Github id, so when you send me your manifest
// I can verify who you are. But it can be anything really.
id: "cyanogen",
// The display summary. Two lines max.
summary: "Mods and bacon for Dream, Sapphire, Droid, and Nexus One",
// The location of the developer's manifest.
manifest: "http://gh-pages.clockworkmod.com/ROMManagerManifest/cyanogenmod.js",
// The list of devices that this developer's ROMs support.
// If you don't support a device, just don't list it!
roms:
{
galaxys: true,
sholes: true
}
}
Send me that file! [email protected]
Link to developer sample: http://gh-pages.clockworkmod.com/ROMManagerManifest/samples/developer.js
And now, create your ROM list file:
Code:
{
// The version of the manifest, so ROM Manager knows how to load it
version: 1,
// The homepage for your ROM, if you have one.
homepage: "http://www.cyanogenmod.com/",
// The donate link for yuor ROM, if you have one.
donate: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3283920",
// Your list of ROMs
roms:
[
{
// Display name of the rom
name: "CyanogenMod 5.0.5",
// Display summary of the rom
summary: "Stable",
// Device that this rom runs on
device: "sholes",
// This is the download URL of your ROM.
// These URLs should have unique filenames per version!
// Ie, don't use a zip with the same name
// as that of a previous version with a new version.
// Otherwise ROM Manager will continue using the
// old cached zip on the SD card.
// This must be a direct download,
// and not a Mediafire type link.
url: "http://www.droidaftermarket.com/koush/motorola/sholes/cyanogen_sholes-ota-eng.koush_5.0.5.zip"
},
// Antother, older ROM!
{
name: "CyanogenMod 5.0.4",
summary: "Stable",
device: "galaxys",
url: "http://www.droidaftermarket.com/koush/motorola/sholes/cyanogen_sholes-ota-eng.koush_5.0.4.zip"
}
]
}
Link to manifest sample: http://gh-pages.clockworkmod.com/ROMManagerManifest/samples/simplemanifest.js
And you're done!
If you're a pro dev, you can even create a ROM customizer. But I won't get into that here
Follow this link for more information: http://www.koushikdutta.com/2010/03/rom-manager-and-third-party-roms.html

Related

MissingManifestResourceException on a bar code reader device

I have a problem in my application. I am developing software for a Windows CE .NET device. It is a bar code reader and I have the library that includes the control of the bar code scanner
When I try to create an object of ScannerServicesDriver type I get a MissingManifestResourceException and no additional information is given.
I don´t understand why can I create the object scanner1 correctly and not the scannerServicesDriver1.
The path of reference to the library is correct
This is the code I have:
public class FormA200 : System.Windows.Forms.Form
{
...
private PsionTeklogix.Barcode.ScannerServices.ScannerServicesDriver scannerServicesDriver1;
private PsionTeklogix.Barcode.Scanner scanner1;
public FormA200()
{
InitializeComponent();
}
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormA200));
this.lCant = new System.Windows.Forms.Label();
.....
this.scanner1 = new PsionTeklogix.Barcode.Scanner();
//at this point the exception happens!
this.scannerServicesDriver1 = new PsionTeklogix.Barcode.ScannerServices.ScannerServicesDriver();
// scanner1
this.scanner1.Driver = this.scannerServicesDriver1;
this.scanner1.ScanCompleteEvent += new PsionTeklogix.Barcode.ScanCompleteEventHandler(this.scanner1_ScanCompleteEvent);
this.Load += new System.EventHandler(this.FormA200_Load);
}
private void scanner1_ScanCompleteEvent(object sender, PsionTeklogix.Barcode.ScanCompleteEventArgs e)
{
}
}
Any ideas??

How to copy file from SDCARD to /data/data/...

Hello everyone, I developed an app which utilizes database.
I implemented a method for backing up the database from /data/data/package_name/databases to the SDCARD wiith the following code
Code:
try {
File path_to_sd = Environment.getExternalStorageDirectory();
File path_to_data = Environment.getDataDirectory();
String current_db_path = "//data//" + getPackageName() + "//databases//";
String path_to_database = path_to_data.getAbsolutePath() + current_db_path;
String backup_name = "backup.db";
File current_db = new File(path_to_database, database_name);
File db_backup = new File(path_to_sd, backup_name);
FileChannel src = new FileInputStream(current_db).getChannel();
FileChannel dst = new FileOutputStream(db_backup).getChannel();
if(!db_backup.exists()){
try {
db_backup.createNewFile();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
Toast.makeText(getApplicationContext(), "Exporting database done successfully!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
the thing is that the above code did the job but created a file with the following permissions ---rwxr-x
so my method for importing the database file from the SDCARD back to the /data/data/pachage_name/databases fail at the line
FileChannel src = new FileInputStream(current_db).getChannel();
and the error is that, no read permission for this file.
How can I fix this issue?
thanks a lot.
needed root
shakash3obd said:
Hello everyone, I developed an app which utilizes database.
I implemented a method for backing up the database from /data/data/package_name/databases to the SDCARD wiith the following code
Code:
try {
File path_to_sd = Environment.getExternalStorageDirectory();
File path_to_data = Environment.getDataDirectory();
String current_db_path = "//data//" + getPackageName() + "//databases//";
String path_to_database = path_to_data.getAbsolutePath() + current_db_path;
String backup_name = "backup.db";
File current_db = new File(path_to_database, database_name);
File db_backup = new File(path_to_sd, backup_name);
FileChannel src = new FileInputStream(current_db).getChannel();
FileChannel dst = new FileOutputStream(db_backup).getChannel();
if(!db_backup.exists()){
try {
db_backup.createNewFile();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
Toast.makeText(getApplicationContext(), "Exporting database done successfully!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
the thing is that the above code did the job but created a file with the following permissions ---rwxr-x
so my method for importing the database file from the SDCARD back to the /data/data/pachage_name/databases fail at the line
FileChannel src = new FileInputStream(current_db).getChannel();
and the error is that, no read permission for this file.
How can I fix this issue?
thanks a lot.
Click to expand...
Click to collapse
since u r trying to copy files to /data/data which is only read only mode ... so u need root access to do your job.....
i have attached a a zip file that contains 4 java files and can be included in your project...
it gives you root access... but writing to /data/data must be implemented by u...
Thank you so much anurag.dev1512.
I will take a look at the files you provided.
I will not be able to get back to you about the result soon since it's almost finals time so I will be busy until December
again, thanks a lot.:good:

Push notifications between devices

Hello!
Sorry for my bad english.
I'm trying to develop an app that send a push notification from device A (android) to device B (android).
How can I make this app?
I can't use GCM/Parse server, 'cause a push notification is sent ONLY from server to device!
I must use a DB that save MY contacts? And then, with a query (?), sent a push notif. to user B (B have downloaded the app, of course!)?
Thanks!
Venus88 said:
I can't use GCM/Parse server,
Click to expand...
Click to collapse
Yes you can, you would just need to create an API that would capture a message sent to the server from device A then send it to device B.
Jonny said:
Yes you can, you would just need to create an API that would capture a message sent to the server from device A then send it to device B.
Click to expand...
Click to collapse
Thanks a lot!
And how I can do that? The code for GCM server, i.e. gcm.php:
PHP:
<?php
class GCM {
//put your code here
// constructor
function __construct() {
}
/**
* Sending Push Notification
*/
public function send_notification($registatoin_ids, $message) {
// include config
include_once './config.php';
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registatoin_ids,
'data' => $message,
);
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
// Close connection
curl_close($ch);
echo $result;
}
}
?>
and
PHP:
<?php
// response json
$json = array();
/**
* Registering a user device
* Store reg id in users table
*/
if (isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["regId"])) {
$name = $_POST["name"];
$email = $_POST["email"];
$gcm_regid = $_POST["regId"]; // GCM Registration ID
// Store user details in db
include_once './db_functions.php';
include_once './GCM.php';
$db = new DB_Functions();
$gcm = new GCM();
$res = $db->storeUser($name, $email, $gcm_regid);
$registatoin_ids = array($gcm_regid);
$message = array("product" => "shirt");
$result = $gcm->send_notification($registatoin_ids, $message);
echo $result;
} else {
// user details missing
}
?>
allows send notification from server page to one/a group of devices.
Can i "reverse" the direction? from Device A to server (and then from server to device B) automatically?
Up :\

Java&WinRAR-(dirthack) to get files >4GB to USB-Disk for Kodi

Hi together,
last year I've installed a 1st-Gen FireTV with Kodi in combination with a 4TB USB HDD for my parents RV. Don't exactly remember how I got the 4TB disk to fat32, but google should provide the answer, since it did for me than. The bigger issue anyway was to get files bigger than 4GB on the disk. The trick for my was to find out, that Kodi can access *.rar archives as if it was a file. So I wrote a java "dirtyhack": It uses a combination of java and WinRAR. Java to determine if a file is bigger than 4GB or not. If it is smaller, just copy the file, if it is bigger, call WinRAR with the right parameters to create a splittet archive consisting of parts smaller than 4GB on the HDD.
So first you choose a source-folder, than select a destination-folder (should be the Disk ) and all files get copied recursively.
As I'm currently updating the HDD and have unsuccessfully searched for an easier way (after I've installed all updates on the ftv *doh!*) I thought I could share my Code, so here you go:
Code:
import javax.swing.*;
import java.io.IOException;
import java.io.*;
/**
* @author der-gee
*
*/
public class Copy {
static int amountFiles = 0;
static long limit = 4294967295L;
/**
* Lists all files from a given folder, recursively
*
* @param dir
* Prints a list of files > 4GB and sums them up
*/
public static void listDir(File dir) {
File[] files = dir.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
listDir(files[i]); // calls itself
} else {
if (files[i].length() > limit) {
System.out.println(files[i].getAbsolutePath());
amountFiles++;
}
}
}
}
}
/**
* Shows a select file dialog and returns the choosen one ^^
*
* @param title
* Title to be shown by the "choose file dialog"
* @return The directory as file
*/
static public File getFolder(String title) {
JFileChooser chooser;
chooser = new JFileChooser();
chooser.setCurrentDirectory(File.listRoots()[0]);
chooser.setDialogTitle(title);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
return chooser.getSelectedFile();
} else {
System.out.println("No Selection ");
return null;
}
}
/**
* Copies directories and files smaller than 4GB
*
* @param src
* @param dest
* @throws IOException
*/
public static void copyFolder(File src, File dest) throws IOException {
if (src.isDirectory()) {
// if directory not exists, create it
if (!dest.exists()) {
dest.mkdir();
System.out.println("Directory copied from " + src + " to "
+ dest);
}
// list all the directory contents
String files[] = src.list();
for (String file : files) {
// construct the src and dest file structure
File srcFile = new File(src, file);
File destFile = new File(dest, file);
// recursive copy
copyFolder(srcFile, destFile);
}
} else {
// if file, then copy it
// Use bytes stream to support all file types
// If file is t large for Fat32 -> rar it
if (src.length() >= limit)
rarThis(src, dest);
else {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int length;
// copy the file content in bytes
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
in.close();
out.close();
System.out.println("File copied from " + src + " to " + dest);
System.out.println("Size from: " + src + ":" +src.length());
}
}
}
/**
* Should use a combination of cmd and winrar to create splitted archives,
* so that they can be stored to a fat32 drive.
*
* @param src
* @param dest
*/
public static void rarThis(File src, File dest) {
String[] command = {
"\"" + "C:\\Program Files\\WinRAR\\rar.exe" + "\"",
"a", "-m0", //a = Archive, -m0 = compressionMode store
"-v3.999g", "-y", //v = VolSize, y = always answer yes
"-ep", //ep = noPath in archive
"\"" + dest.getAbsolutePath().replace("mkv", "rar") + "\"",
"\"" + src.getAbsolutePath() + "\"" };
Runtime rt = Runtime.getRuntime();
try {
Process rar = rt.exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(rar.getInputStream()));
String line;
while ((line = reader.readLine()) != null)
System.out.println("WinRAR: " + line);
rar.waitFor();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
}
}
/**
* Main program. Initiates the whole thing :)
*
* @param s
* @throws IOException
*/
public static void main(String s[]) throws IOException {
System.out.println("Size limit: " + limit);
File sourcePath = getFolder("Source");
if (sourcePath != null) {
listDir(sourcePath);
System.out.println("Amount files > 4GB: " + amountFiles);
}
File targetPath = getFolder("Destination");
copyFolder(sourcePath, targetPath);
System.out.println("Finished!");
}
}
I wrote this for Windows, using the x64 Version of WinRar, so if you are using the 32-bit version, you have to adjust the rar folder in the rarThis function. Feel free to use and share. If you have improvements, please share
Interesting. When I came to this problem of HD files larger than 4 GB I decided to use the NTFS format and then use Paragon to mount the external HDD on my rooted Fire TV.
PhoenixMark said:
Interesting. When I came to this problem of HD files larger than 4 GB I decided to use the NTFS format and then use Paragon to mount the external HDD on my rooted Fire TV.
Click to expand...
Click to collapse
Hehe, I would have done the same, but I checked for root after upgrading to the very last fw version
PhoenixMark said:
Interesting. When I came to this problem of HD files larger than 4 GB I decided to use the NTFS format and then use Paragon to mount the external HDD on my rooted Fire TV.
Click to expand...
Click to collapse
Was this on the latest rooted firmware? I have a AFTV2 running the latest prerooted rom from rbox
deanr1977 said:
Was this on the latest rooted firmware? I have a AFTV2 running the latest prerooted rom from rbox
Click to expand...
Click to collapse
I'm using 5.0.5 because I like using FireStarter, but I don't see why you can't still do this on 5.0.5.1 as well as there is a pre rooted rom for it. Only difference is you need the A to A USB cable to root 5.0.5.1.

[Tutorial] Developing Cloud Base App [GoogleCloud][Android]

{
"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"
}
​ In this Tutorial I try to explain general aspects of Cloud Computing & Cloud Concepts & Authentication You will learn What is Cloud & If already know basics of Android Programming, you will be able to develop your Cloud Base App after reading carefully this guide.
Featured By XDA
Aamir Siddiqui | May 19, 2016
XDA Senior Member Geeks Empire has posted an extensive tutorial on developing a cloud based app.
The tutorial teaches users how to make use of Google Cloud and Firebase to achieve their goals.
Click to expand...
Click to collapse
Why are so many businesses moving to the cloud? It’s because cloud computing increases efficiency, helps improve cash flow and offers many more benefits…Here's ten of the best.
1. Flexibility
2. Disaster recovery
3. Automatic software updates
4. Capital-expenditure Free
5. Increased collaboration
6. Work from anywhere
7. Document control
8. Security
9. Competitiveness
10. Environmentally friendly
READ MORE
Click to expand...
Click to collapse
If you want to design & develop cloud service for your business it is better to understand What you Know & Need.
Cloud Services categorized into 3 basic models:
- Infrastructure-as-a-Service (IaaS)
- Platform-as-a-Service (PaaS)
- Software-as-a-Service (SaaS)
Click to expand...
Click to collapse
Try to read again carefully All descriptions & Link above to get reach knowledge of Cloud.
In This Tutorial I used All Alphabet Services. Google Cloud, Firebase, Google Play Services & etc.
I prefer Alphabet cause It is Google
“Firebase — a powerful platform for building iOS, Android, and web-based apps, offering real-time data storage and synchronization, user authentication, and more.”
Click to expand...
Click to collapse
INDEX
* Data Transferring *
- FireBase Cloud Service
* Authentication *
- Google Account By GoogleSignIn API
- Twitter By Fabric API
- Email/Pass By Firebase API
# Let Start #
What you Need to Continue is;
1. Google Account
2. Ability to Create Hello World! Project in Android Studio
Click to expand...
Click to collapse
* Application Configuration
Run Android Studio & Create New Project with Blank Activity. (Set Proper AppName & Package)
After Gradle Building finished go to File > Project Structure > Cloud & Enable Firebase.
Go to Manifest > Add Get_Account & Internet Permissions above the <application />
Code:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
then Inside Application tag add Google_Play_Service <meta-data />
Code:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Then Open build.gradle (Module: App) & Add these excludes to prevent errors during test process inside android{}
Code:
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
Also Add this library for auth-process into dependencies{}
Code:
compile 'com.google.android.gms:play-services-auth:8.4.0'
Now your App is Ready to Add Codes for Cloud API But your Need to Configure Cloud Side too.
* Google Cloud & Firebase Configuration
Here some parts doesn't need for beginning Android Coding But It can be tricky & easy for you to do everything on Browser for Google Section and then Focus on Coding. At End you can Review All Parts & Test it by yourself. I will explain more about each part.
Generate your Sign APK to Get SHA-1 Key
Code:
keytool -list -v -keystore '/PATH/TO/kEY_STORE'
To Transfer Data to Cloud you need to Have a Cloud Service. Here I am using Firebase.
Go to www.Firebase.com & Login with your Google Account.
Firebase will automatically Create a Project for you named 'MY FIRST APP' that you can delete or modify it.
Firebase has Free Plan for Small Business, Testing & etc. So after you learn more about cloud you can upgrade your plan for existing projects.
The URL of Firebase for your Project is Like this​
HTML:
https://YOUR_APP_NAME.firebaseio.com/
Every task with Firebase API needs this URL.
Go to https://Console.Gloud.Google.com Sign-Up & Get 60 Days Trial Period & 300$ to spend on Google Cloud Platform.
So Feel Free to Create Projects & Enabling APIs.
After Creating Google Cloud Project go to Project Dashboard & from Left Panel navigate to API Manager > Credentials. Click on Create Credential & Select OAuth client ID After Loading New Page Select Android Then Create. Now Set Carefully your SHA-1 key & Android App PackageName then Save.
Go to https://Developers.Google.com/ First of All If you are new to Developing Spend some times in this page & Enjoy All Google Services for Everything. :good:
Then Navigate to Google Service for Mobile > Android > Sign-In with Google > Click Get Start > Scroll Down > Click Get Configuration File.
Again Type your Android App PackageName then Click Continue & Type SHA-1 Key & Click ENABLE GOOGLE SIGN-IN after that Scroll Down and Click on Generate Configuration File and Download the File.
Copy google-service.json File & Paste it to App Level Project.
Code:
To do this Now Open Android Studio Change View of Project Explorer from Android View to Project View.
Expand Project and Paste JSON file under the APP Level.
http://dl-1.va.us.xda-developers.co....jpg?key=fJhht_mZE9VqhL4UuJvbow&ts=1464144452
Now you are ready to use Firebase Services & Login with Google.
Next Post is About Working with Firebase Send/Receive Data.
Oo. DOWNLOAD .oO
SOURCE.CODE
APK.FILE
​
Thanks for Supporting GeeksEmpire projects
​Don't Forget To Hit Thanks
​
Google Cloud & Firebase [Data Transferring]
​Now It is time to Focus on Coding. It is not difficult to understand Firebase API But Using URL carefully to Create New User, Data, Section & etc is important.
Open MainActivity.Java
At First the Class must extended from Fragment that required for Firebase API (& later for Google Sign-In). In this case I use AppCompatActivity.
Code:
public class MainActivity extends AppCompatActivity{}
To work with Firebase API you have to define it like other objects.
You can do it when you need it Or define it at first part of app onCreate(Bundle){}
Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
[B]Firebase.setAndroidContext(getApplicationContext());[/B]
After that you need to declare instance of your views. For Example I declare ListView that will use for showing loaded Data.
Code:
ListView listView = (ListView)findViewById(R.id.listView);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1);
//built-in adaptor
listView.setAdapter(adapter);
NOTE: Save your Firebase URL to <resource> <string /></resource> Or Save it as Universal String Object inside Class.
For Example Before onCreate(Bundle)
Code:
String FirebaseLink = "https://[B]YOUR_APP_NAME[/B].firebaseio.com/";
String FirebaseTitle = "GeeksEmpire";
String FirebaseSub = "gX";
To Get Data from User you should define input method like <EditText/>
With This methods you can Save Data Locally in Application Private Storage on System
Code:
//Save Content
try {
FileOutputStream fOut = openFileOutput(NAME, MODE_PRIVATE);
fOut.write((DATA).getBytes());
//Always Close All Streams
fOut.close();
fOut.flush();
}
catch (Exception e) {
System.out.println(e);
} finally {}
Code:
//Read-File
public String READ(String S, Context context){
File Fav = new File(S);
String Read = null;
FileInputStream fin;
BufferedReader br = null;
try{
fin = new FileInputStream(Fav);
br = new BufferedReader(new InputStreamReader(fin, "UTF-8"), 1024);
System.out.println(br);
int c;
String temp = "";
while( (c = br.read()) != -1){temp = temp + Character.toString((char)c);}
Read = temp;}
catch(Exception e)
{System.out.println(e);}
finally{try {br.close();} catch (IOException e) {e.printStackTrace();}}
return Read;
}
But to Store Data on Firebase Server you should declare instance of Firebase API, Push & setValue(DATA)
Code:
upload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String DATA = editText.getText().toString();//"[COLOR=Red][I]GeeksEmpire DataBase on FireBase[/I][/COLOR]"
new Firebase([B]FirebaseLink[/B]/*[COLOR=Red][I]https://YOUR_APP_NAME.firebaseio.com[/I]/[/COLOR]*/ + FirebaseTitle/*[COLOR=Red][I]GeeksEmpire[/I][/COLOR]*/)
.push()
.child(FirebaseSub/*[COLOR=Red][I]gX[/I][/COLOR]*/)
.setValue(DATA);
}
});
Compare red texts with image. Firebase URL is submitted but you can Modify both FirebaseTitle & FirebaseSub.
In this Case I used GeeksEmpire as Title & gX as SubTitle & then Data.
It is depend on your design.
you can set GeeksEmpire as User & gX as Title OR Whatever you need.​
Data Uploaded to Server & Now you should make an option to Download them. I created function to gather all components.
Code:
public void SetUpCloudContent(){
Firebase.setAndroidContext(this);
new Firebase(FirebaseLink/*[COLOR=Red]https://YOUR_APP_NAME.firebaseio.com/[/COLOR]*/ + FirebaseTitle/*[COLOR=Red]GeeksEmpire[/COLOR]*/).addChildEventListener(new ChildEventListener() {
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
adapter.add((String)dataSnapshot.child(FirebaseSub/*[COLOR=Red]gX[/COLOR]*/).getValue());//add each value to ListView
}
public void onChildRemoved(DataSnapshot dataSnapshot) {
adapter.remove((String)dataSnapshot.child(FirebaseSub).getValue());
}
public void onChildChanged(DataSnapshot dataSnapshot, String s) { }
public void onChildMoved(DataSnapshot dataSnapshot, String s) { }
public void onCancelled(FirebaseError firebaseError) { }
});
}
To Change Data Just Use ID you got to User (For Example GeeksEmpire > gX) and OverWrite Data.
But here is a method to Delete Data.
// Delete items when clicked
Code:
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
new Firebase([COLOR=Red]FirebaseLink [/COLOR]+ [COLOR=Red]FirebaseTitle[/COLOR])
.orderByChild([COLOR=Red]FirebaseSub[/COLOR])
.equalTo((String) listView.getItemAtPosition(position)/*[I]get data from ListView[/I]*/)
.addListenerForSingleValueEvent(new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.hasChildren()) {
DataSnapshot firstChild = dataSnapshot.getChildren().iterator().next();
firstChild.getRef().removeValue();
}
}
public void onCancelled(FirebaseError firebaseError) { }
});
return false;
}
});
Sending & Receiving Data to Firebase Cloud Service is Done.
Again It depends on you How to define Users & Create Individual ID for each one.
Next Posts Will Show How to Create Sign-In Options for your App. That Also Help a lot to create Individual ID.
Thanks for Supporting GeeksEmpire projects
​Don't Forget To Hit Thanks​
Google Account [Authentication]
​I used Google API for Google Account Auth cause you can get more info about Google Account to use and customize your App. Info that you cannot retrieve by Firebase.Auth("google"). For Example Account Pic to Use inside your app for user.
(Set Google Account Pic as Pic of Account on your App)
In First Post Google Sign-In Setup Completed.
Sign-In API Enabled & Configuration file add to Project.
Another modification needed to apply on build.gradle (Module: App)
Add this plugin at end of your gradle file.
Code:
apply plugin: 'com.google.gms.google-services'
& Also for build.gradle (Project)
Add this classpath under dependencies {}
Code:
classpath 'com.google.gms:google-services:2.0.0-alpha5'
You should Implement you class to GoogleApiClient.ConnectionCallbacks & GoogleApiClient.OnConnectionFailedListener.
& Add required methods.
Code:
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {}
@Override
public void onConnected(@Nullable Bundle bundle) {}
@Override
public void onConnectionSuspended(int i) {}
Define GoogleApiClient as universal variable (Outside of any Function).
Get instance of GoogleApiClient & GoogleSignInOptions onCreate(Bundle).
Code:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)//FragmentActivity
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
To perform Sign Action normally button used If you don't want to do it at start up of app.
For this Google Service has its own button design that used in sample. However you can design your own view.
Code:
<com.google.android.gms.common.SignInButton />
Like other Android system function calling we should use Intent to Invoke Google Account Chooser and Get Result on CallBack.
Code:
google.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, [COLOR=Red]7[/COLOR]);
}
});
On result CallBack you should declare GoogleSignResult
Code:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == [COLOR=Red]7[/COLOR]){
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if(result.isSuccess()){
//[B]Handle Security Inside App[/B]
GoogleSignInAccount acct = result.getSignInAccount();
Toast.makeText(getApplicationContext(), "getEmail >> " + [B]acct.getEmail()[/B], Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "getDisplayName >> " + [B]acct.getDisplayName()[/B], Toast.LENGTH_LONG).show();
//Can get more Info by using GoogleSignInAccount
}
}
NOTE: You can use Google Account as UserName for your Users on Firebase & By Calling Sign-In Process at App Start Provide Security for your App.
Thanks for Supporting GeeksEmpire projects
​Don't Forget To Hit Thanks​
Twitter Account [Authentication]
​ Authentication by Twitter has Complex aspect.
First you should Create Twitter Account, Then Create Web App through www.twitter.com (to get Public & Secret Key), Enable Twitter on Firebase (Not Required But I recommend it) & Install 3rd-Party Plugin on Android Studio (Fabric API).
Go to https://twitter.com/ & Sign Up then go to https://apps.twitter.com/ & Create App.
Name the App & Write Description & WebSite.
In App Page > Keys & Access Token
. Consumer Key (API Key) = XXXXX
. Consumer Secret (API Secret) = XXXXX
Save these value to resources of your app. res > values > string
Code:
</resources>
<string name="twitter_consumer_key">[B]API Key[/B]</string>
<string name="twitter_consumer_secret">[B]API Secret[/B]</string>
</resources>
- Go to Login & Auth on Firebase Select Twitter & Paste API Key + API Secret.
On Android Studio navigate to File > Setting > Plugin& Search for Fabric (Click Browse)
After Plugin Downloaded It will ask for Restart to Complete Installation.
Then Fabric Plugin icon will appear on toolbar & maybe Right-Panel. ​
​Click on Plugin & Sign Up. Then you will see your current project on Fabric list. Select it & click Next.
From List of All Kits select Twitter & click Install. It will ask for API Key + API Secret
Fabric will Apply All Modification it needs to your project & after that you project will be ready for Twitter Auth.
But for Developer It is always important points to understand every part of tools and apps.
* Fabric Inside build.grade (Module: App)
before Android Plugin
Code:
apply plugin: 'com.android.application'
Add this Script
Code:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
after Android Plugin set up fabric plugin
Code:
apply plugin: 'io.fabric'
after android{} functions add Fabric Repositories
Code:
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
& Inside dependencies{} add
Code:
compile('com.twitter.sdk.android:twitter:[email protected]') {
transitive = true;
}
* Fabric Inside Manifest
in <application/> add
Code:
<meta-data
android:name="io.fabric.ApiKey"
android:value="API_KEY" />
* Fabric Inside MainActivity Class
before setContentView(VIEW) under onCreate(Bundle)
Code:
TwitterAuthConfig authConfig = new TwitterAuthConfig([COLOR=Red]API_KEY[/COLOR], [COLOR=Red]API_SECRET[/COLOR]);
Fabric.with(this, new Twitter(authConfig));
Fabric Also provides Button design for Twitter with custom features to handle Auth CallBack.
Code:
<com.twitter.sdk.android.core.identity.TwitterLoginButton/>
You define it in layout.xml & then Declare it like normal views on activity.
But performing action is different.
Code:
/*TWITTER Sign-In*/
twitterButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
Toast.makeText(getApplicationContext(), [COLOR=Red][B]result[/B][/COLOR].data.getUserName(), Toast.LENGTH_LONG).show();
}
@Override
public void failure(TwitterException exception) {}
});
without any extra Intent it will redirect you to Twitter Auth Page.
Also By using this button you can handle CallBack Result.
Code:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
twitterButton.onActivityResult(requestCode, resultCode, [COLOR=Red][B]data[/B][/COLOR]);
}
Also I used Fabric for Twitter Auth cause I can retrieve more Info than Firebase.Auth("twitter").
Fabric Plugin Developed by Twitter Developers So It really works smoothly & really best way to Auth with Twitter Account.
Thanks for Supporting GeeksEmpire projects
​Don't Forget To Hit Thanks​
Email/Password Account [Authentication]
Auth with Email/Password Using Firebase API is so simple.
Go to Firebase Project Dashboard > Login & Auth & Enable Email & Password Authentication
Define 2 <EditText /> for Email & Password in layout.xml Don't forget to set inputType
Code:
[CENTER][LEFT]Email
<EditText
android:id="@+id/email"
android:inputType="textEmailAddress" />
[/LEFT]
[/CENTER]
Password
<EditText
android:id="@+id/password"
android:inputType="textPassword" />
Declare Firebase & then Set Auth method.
Code:
//Remember from first post
Firebase ref = new Firebase(FirebaseLink/*[COLOR=Red]https://FIREBASE_PROJECT_NAME.firebaseio.com/[/COLOR]*/);
Define Login/SignUp Button and onClick setup Email/Pass Auth
Code:
//E-MAIL SignUp
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "User Created", Toast.LENGTH_LONG).show();
String email = user.getText().toString();
String pass = password.getText().toString();
Firebase ref = new Firebase([COLOR=Red]FirebaseLink[/COLOR]);
ref.createUser([COLOR=Red][B]email[/B][/COLOR], [COLOR=Red][B]pass[/B][/COLOR], new Firebase.ValueResultHandler<Map<String, Object>>() {
@Override
public void onSuccess(Map<String, Object> result) {
System.out.println("Successfully created user account with uid: " + result.get("uid"));
}
@Override
public void onError(FirebaseError firebaseError) {
// there was an error
}
});
}
});
Code:
//E-MAIL Login
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = user.getText().toString();
String pass = password.getText().toString();
Firebase ref = new Firebase([COLOR=Red]FirebaseLink[/COLOR]);
ref.authWithPassword([COLOR=Red][B]email[/B][/COLOR], [COLOR=Red][B]pass[/B][/COLOR], new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
System.out.println("User ID: " + authData.getUid() + ", Provider: " + authData.getProvider());
Toast.makeText(getApplicationContext(), "User Authenticated", Toast.LENGTH_LONG).show();
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {}});
}}
});
For this everything provided simply by Firebase API. You completely Handle all process.
Here are more helpful Functions.
Code:
public void [B]ResetPassword[/B](String [COLOR=Red]E_MAIL_ADDRESS[/COLOR]){
Firebase ref = new Firebase("https://[COLOR=Red]<YOUR-FIREBASE-APP>[/COLOR].firebaseio.com");
ref.resetPassword([COLOR=Red]E_MAIL_ADDRESS[/COLOR], new Firebase.ResultHandler() {
@Override
public void onSuccess() {
// password reset email sent
}
@Override
public void onError(FirebaseError firebaseError) {
// error encountered
}
});
}
Code:
public void [B]ChangePassword[/B](String [COLOR=Red]E_MAIL[/COLOR], String [COLOR=Red]oldPass[/COLOR], String [COLOR=Red]newPass[/COLOR]){
Firebase ref = new Firebase("https://[COLOR=Red]<YOUR-FIREBASE-APP>[/COLOR].firebaseio.com");
ref.changePassword([COLOR=Red]E_MAIL[/COLOR], [COLOR=Red]oldPass[/COLOR], [COLOR=Red]newPass[/COLOR], new Firebase.ResultHandler() {
@Override
public void onSuccess() {
// password changed
}
@Override
public void onError(FirebaseError firebaseError) {
// error encountered
}
});
}
Code:
public void [B]RemoveAccount[/B](String [COLOR=Red]E_MAIL[/COLOR], String [COLOR=Red]Password[/COLOR]){
Firebase ref = new Firebase("https://[COLOR=Red]<YOUR-FIREBASE-APP>[/COLOR].firebaseio.com");
ref.removeUser([COLOR=Red]E_MAIL[/COLOR], [COLOR=Red]Password[/COLOR], new Firebase.ResultHandler() {
@Override
public void onSuccess() {
// user removed
}
@Override
public void onError(FirebaseError firebaseError) {
// error encountered
}
});
}
Thanks for Supporting GeeksEmpire projects
​Don't Forget To Hit Thanks
​
Info
If you find any mistake Or issue in my codes Please inform me.
Click to expand...
Click to collapse
I will try to Keep this Tutorials Up-to-Date.
Also Add Guide for Other Cloud Services.
Check Out my Open Source Android Applications & Tutorials in my Signature. :good:
Google Firebase.Storage
​
It s time to do something important with Cloud Service; Upload & Download File.
Google Cloud Service (Firebase) has lots of Useful Features + Really Straight & Manageable API.
First Read Preface Post & Firebase Basics to Prepare your Project for Cloud Services.
Now you will Understand upcoming codes.
Inside build.gradle of AppLevel declare Firebase.Storage SDK in dependencies
Code:
compile 'com.google.firebase:firebase-[B]storage[/B]:9.0.2'
compile 'com.google.firebase:firebase-[B]auth[/B]:9.0.2'
In update Sample Code I created new activity to handle Files. You can do whatever you like.
NOTE: You have to Authenticate Users with Firebase Services to Perform any Server action. For example Uploading File. check out SourceCode
In activity onCreate() declare instance of Firebase.Storage & Firebase.Auth
Code:
firebaseStorage = [B]FirebaseStorage[/B].getInstance();
firebaseAuth = [B]FirebaseAuth[/B].getInstance();
To Perform Both Upload & Download Task you need to create a Reference.
There is different method for creating StorageReference that I chose:
Code:
getReferenceFromUrl() for Uploading
& getFile() for Downloading.
Before anything do Auth Process. As Public APP I used Anonymously option & call the function when Activity Start.
Code:
private void signInAnonymously() {
mAuth.signInAnonymously().addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {}
}).addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {}
});
}
Now you can Add StorageReference & Perform Actions
UPLOAD Function check out SourceCode
Code:
private void uploadFromUri(InputStream fileUri) {
StorageReference mStorageRef = storage.getReferenceFromUrl("gs://[I][COLOR=Red][B][YOUR_FIREBASE_PROJECT_LINK][/B][/COLOR][/I]/");
StorageReference photoRef = mStorageRef.child("Dir").child("File");
UploadTask uploadTask = photoRef.putStream(fileUri);
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
System.out.println("DONE!");
//Get Download Address for Future
Uri dl = taskSnapshot.getMetadata().getDownloadUrl();
//Save Download Address in App Dir
SharedPreferences sharedpreferences = getSharedPreferences("Info", Context.MODE_PRIVATE);
SharedPreferences.Editor dlLink = sharedpreferences.edit();
dlLink.putString("path", String.valueOf(dl));
dlLink.apply();
infoFile.append("\n" + dl.getPath());
System.out.println("Download >> " + dl);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
System.out.println("!Damn!");
}
});
}
DOWNLOAD Function check out SourceCode
Code:
public void downloadFromUri(StorageReference storageRef) throws Exception {
//Create File
final File localFile = new File(Environment.getExternalStorageDirectory().getPath() + "/CloudAppTest_GeeksEmpire.jpg");
storageRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
System.out.println("DONE!");
//Using Downloaded File
Bitmap bitmap = BitmapFactory.decodeFile(localFile.getAbsolutePath()); System.out.println("Downloaded >> " + localFile.getAbsolutePath());
imageFile.setImageBitmap(bitmap);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
}
For Deleting & any Modification you Just Need to Declare StorageReference & Call Functions. check out SourceCode
Thanks for Supporting GeeksEmpire projects
​Don't Forget To Hit Thanks​
Firebase.RemoteConfiguration
​
The Most Interesting Features from Google Firebase is Remote Configuration.
It is not difficult to Apply & Super Helpful.
By Adding this Feature to your App you can Remotely Change Value of Defined Variable.
It can be String of InApp Texts Or Integer of InApp Color. Whatever you decide to remotely Config.
And Also Conditional Value. For Example Specific Price Tag for a Region Or even a Single User.
Google Cloud Service (Firebase) has lots of Useful Features + Really Straight & Manageable API.
Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update...
Click to expand...
Click to collapse
First Read Preface Post & Firebase Basics to Prepare your Project for Cloud Services.
Now you will Understand upcoming codes.
Inside build.gradle of AppLevel declare Firebase.Storage SDK in dependencies.
Code:
compile 'com.google.firebase:firebase-config:9.0.2'
Create xml folder into the res directory res/xml.
Now create remote_config_default.xml file to define all default Value & KEY for remote configuration.
For Example: check out SourceCode
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- START xml_defaults -->
<defaultsMap>
<entry>
[B]<key>[COLOR=Red]KeyToChange[/COLOR]</key>
<value>[COLOR=Red]Content To Change[/COLOR]</value>[/B]
</entry>
</defaultsMap>
<!-- END xml_defaults -->
You Should go to Firebase Console & you Project Dir & Select Remote Config from Left Panel.
Set <key>KeyToChange</key>& Create New Content.
Now go to your Activity Class that want to Handle these changes from cloud & declare FirebaseRemoteConfig & Set Default Value that defined in XML file. check out SourceCode
Code:
firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.remote_config_default);
after that you can perform to check If there is New Content & Apply it to your App. check out SourceCode
Code:
public void GetNewContent(){
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d("", "Fetch Succeeded");
// Once the config is successfully fetched it must be activated before newly fetched
// values are returned.
mFirebaseRemoteConfig.activateFetched();
} else {
Log.d("", "Fetch failed");
}
[B]//Handle New Content[/B]
textView.setText([B]firebaseRemoteConfig.getString([COLOR=Red]KeyToChange[/COLOR]_String)[/B]);
}
});
}
Thanks for Supporting GeeksEmpire projects
​Don't Forget To Hit Thanks
​
RESERVED 9th
RESERVED 10th
Needed
This tutorial is awesome!
complete and easy to understand
there is few guide about using cloud services
really appreciate :good:
getapp said:
This tutorial is awesome!
complete and easy to understand
there is few guide about using cloud services
really appreciate :good:
Click to expand...
Click to collapse
Thanks for Rating & Review
I am waiting for FeedBackof all users/devs
:good:
Info
James5712 said:
Really good
Click to expand...
Click to collapse
Thanks for Rating & Review :good:
I am waiting for FeedBack of all Users/Devs
Info
Featured By XDA
​
Top Forum Discussions
Aamir Siddiqui | May 19, 2016
XDA Senior Member Geeks Empire has posted an extensive tutorial on developing a cloud based app.
The tutorial teaches users how to make use of Google Cloud and Firebase to achieve their goals.
Click to expand...
Click to collapse
Thanks for Support XDA-Developer :good:
I am waiting for FeedBack of all Users/Devs
Thanks for your effort :good:
I'm newbie in android programming, but i find this tutorial is usefull :good:
Info
iprabu said:
Thanks for your effort :good:
I'm newbie in android programming, but i find this tutorial is usefull :good:
Click to expand...
Click to collapse
Thanks for Rating & Review
+ There is lots of Android Programming Tutorial by GeeksEmpire
you can find all off them in my signature Or Geeky Tutorial
Also Almost All GeeksEmpire Apps on Google Play Store is OpenSource with Full Code Comments
So you can Check them to learn more
you can find all off them in my signature Or Geeky Open Source Project
Don't Forget to hit Thanks :good:
I am waiting for FeedBack of all Users/Devs
thank you
thank you
black_host said:
thank you
Click to expand...
Click to collapse
Your Welcome.
Remember There is more to come to cover all aspect of Cloud Base Developing
+ Don't Forget to hit Thanks
I am waiting for FeedBack of all Users/Devs
Nice Tutorial will definitely recommend to new devs
Info
AonSyed said:
Nice Tutorial will definitely recommend to new devs
Click to expand...
Click to collapse
Thanks for Rating & Review :good:
These Tutorials are beginning of great lesson for Cloud Base App
I am waiting for FeedBack of all Users/Devs

Categories

Resources