GithubHelp home page GithubHelp logo

prgpascal / android-qr-data-transfer Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 583 KB

Library that provides a secure data transmission channel between Android devices.

License: Apache License 2.0

Kotlin 100.00%

android-qr-data-transfer's Introduction

android-qr-data-transfer

Library that provides a secure data transmission channel between Android devices. It uses QR codes and Bluetooth technologies.

Why is it secure?

Because data is exchanged via sequences of QR codes, while a Bluetooth channel is used for acknowledgement (ACK) messages only.

Features

  • During the transmission, the sender device will act as a Server in a Client-Server architecture, while the receiver will serve as a Client.
  • It uses the stop-and-wait protocol.
  • It receives an ArrayList<String> as input parameter, containing all the messages to be exchanged. For each String, a new QR code will be created.
  • Every exchanged message is checked with a digest (SHA-256).

Import dependency

You can use JitPack to import this library into your project.
Put this into your build.gradle:

repositories {
  maven {
    url "https://jitpack.io"
  }
}

dependencies {
  implementation 'com.github.prgpascal:android-qr-data-transfer:2.0.0'
}

Usage

A demo module is available as a working example.

The Server starts the Activity passing an ArrayList<String> as a parameter, containing the messages to be sent:

val intent = Intent(this, ServerTransferActivity::class.java)
val bundle = Bundle()
bundle.putStringArrayList(TransferParams.PARAM_MESSAGES, chunkedTextToTransfer)
intent.putExtras(bundle)
startActivityForResult(intent, DATA_EXCHANGE_REQUEST)

The Client starts the Activity:

val intent = Intent(this, ClientTransferActivity::class.java)
startActivityForResult(intent, DATA_EXCHANGE_REQUEST)

Client and Server can handle the response in the onActivityResult(...) method:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == DATA_EXCHANGE_REQUEST) {
        if (resultCode == RESULT_OK) {
            val messages: List<String> = data?.getStringArrayListExtra(TransferParams.PARAM_MESSAGES) ?: emptyList()
            ...
        } else {
            val error = data?.getStringExtra(TransferParams.PARAM_ERROR)
	    ...
        }
    }
}

The TransferParams class provides a set of different responses and errors returned as IntentExtras:

  • PARAM_I_AM_THE_SERVER: true if the device handling the request is the Server, false otherwise.
  • PARAM_MESSAGES: List of messages exchanged.
  • PARAM_ERROR: String representing an error that occurred:
    • ERROR_BT_NOT_AVAILABLE: if the device doesn't support Bluetooth.
    • ERROR_BT_DISABLED: if the device has Bluetooth turned off.
    • ERROR_PERMISSIONS_NOT_GRANTED: if the user didn't grant all the required runtime permissions.
    • ERROR_NO_DEVICE_SELECTED: if the user did not select a device in the Bluetooth devices list.

Dependencies

android-qr-data-transfer depends on the following external libraries:

License

Copyright 2016 Riccardo Leschiutta

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-qr-data-transfer's People

Contributors

prgpascal avatar

Stargazers

Tom Xin avatar  avatar

Watchers

 avatar  avatar

Forkers

meimingle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.