Skip to content

Instantly share code, notes, and snippets.

View sbis04's full-sized avatar

Souvik Biswas sbis04

View GitHub Profile
@sbis04
sbis04 / AndroidManifest.xml
Created June 24, 2019 08:12
flutter_os_manifest
<!-- Required for ambient mode support -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Flags the app as a Wear app -->
<uses-feature android:name="android.hardware.type.watch" />
<!-- Flags that the app doesn't require a companion phone app -->
<application>
<meta-data
android:name="com.google.android.wearable.standalone"
@sbis04
sbis04 / pubspec.yaml
Created June 24, 2019 07:42
flutter_os_pubspec
dependencies:
audioplayers: ^0.7.8
wear: ^0.0.3
$ flutter create my_app
@sbis04
sbis04 / QueryUtils.java
Created April 10, 2019 14:00
How to parse JSON in Android
package com.example.android.quakereport;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
@sbis04
sbis04 / CategoryAdapter.java
Created April 8, 2019 08:19
Using Tabbed Layout and View Pager
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class CategoryAdapter extends FragmentPagerAdapter {
private Context mContext;
@sbis04
sbis04 / MainActivity.java
Created April 8, 2019 08:11
Using Tabbed Layout with ViewPager
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@sbis04
sbis04 / AndroidManifest.xml
Last active March 5, 2019 08:52
overriding the error in manifest
<manifest ...
<!-- Add this line (inside manifest tag) -->
xmlns:tools="http://schemas.android.com/tools">
<!-- and this line (outside manifest tag) -->
<uses-sdk tools:overrideLibrary="io.github.edufolly.flutterbluetoothserial"/>
....
</manifest>
@sbis04
sbis04 / main.dart
Created March 4, 2019 18:01
Sending message to Bluetooth Module
...
// Method to send message,
// for turning the bletooth device on
void _sendOnMessageToBluetooth() {
bluetooth.isConnected.then((isConnected) {
if (isConnected) {
bluetooth.write("1");
show('Device Turned On');
}
});
@sbis04
sbis04 / main.dart
Created March 4, 2019 17:58
Implementing _connect, _disconnect and show methods
...
// Method to connect to bluetooth
void _connect() {
if (_device == null) {
show('No device selected');
} else {
bluetooth.isConnected.then((isConnected) {
if (!isConnected) {
bluetooth
.connect(_device)
@sbis04
sbis04 / main.dart
Created March 4, 2019 17:53
_getDeviceItems( ) method
...
// Create the List of devices to be shown in Dropdown Menu
List<DropdownMenuItem<BluetoothDevice>> _getDeviceItems() {
List<DropdownMenuItem<BluetoothDevice>> items = [];
if (_devicesList.isEmpty) {
items.add(DropdownMenuItem(
child: Text('NONE'),
));
} else {
_devicesList.forEach((device) {