dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile files('src/main/libs/fptrlib.jar') compile project(':fptrLibRes') }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ru.kkm"> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.atol.drivers.fptr.settings.SettingsActivity" android:label=" " android:windowSoftInputMode="adjustPan"> <intent-filter> <action android:name="android.intent.action.VIEW"/> </intent-filter> </activity> <activity android:name="com.atol.drivers.fptr.settings.DeviceListActivity" android:configChanges="orientation|keyboardHidden" android:label=" "/> </application> </manifest>
package ru.kkm; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import com.atol.drivers.fptr.IFptr; import com.atol.drivers.fptr.settings.SettingsActivity; public class MainActivity extends AppCompatActivity { IFptr fptr = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try{ fptr = new IFptr(); fptr.create(this); } catch (NullPointerException ex){ fptr = null; } } public void onClick(View view){ switch (view.getId()){ case R.id.button: Intent intent = new Intent(this, SettingsActivity.class); intent.putExtra(SettingsActivity.DEVICE_SETTINGS, fptr.get_DeviceSettings()); startActivityForResult(intent, 1); break; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == 1){ if(data!=null && data.getExtras()!=null){ String settings = data.getExtras().getString(SettingsActivity.DEVICE_SETTINGS); Toast.makeText(this, settings, Toast.LENGTH_LONG).show(); } } } }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="ru.cse.kkm_test.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" android:id="@+id/textView" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" android:onClick="onClick" android:layout_below="@+id/textView" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="46dp" /> </RelativeLayout>
Source: https://habr.com/ru/post/308900/
All Articles