vText Voice password does not load on Android - java

For my semester project I am trying to identify speaker on Android. For this purpose, I have been trying to integrate vText java library to Android Studio. You can find the page through this link. However, I got the .jar files which are mentioned in the web page and tried to do sample things for discovering the library and I got java.lang.VerifyError. Of course I searched for it but did not get anything handy.I tried to change JDK version but I could not make it,too. If anyone can help me for using this library in Android Studio properly.
Here is my code part relevant to this problem.
btnVoice.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
CountDownTimer countDownTimer=new CountDownTimer(5000,1000) {
#Override
public void onTick(long millisUntilFinished) {
btnVoice.setText(millisUntilFinished/1000 + " seconds.");
}
#Override
public void onFinish() {
stopRecording();
try {
vTText=new vTextClass();
vTText.dataAcq(1, filename);
System.out.println("Recording completed");
} catch (MWException e) {
e.printStackTrace();
}
}
}.start();

This library uses matlab component runtime, which is not available on android. See How to run Matlab code on an Android device?
You can use other framework instead like Recognito

Related

How to rotate mp4 files?

I have a mp4 file(already recorded) and want to change the rotation(including meta data) of the video. There is a way to do this using Hex Editor where in you find the track header(tkhdr) and replace the rotation matrix with the required rotation.
I know this can be done using ffmpeg library but I do not want to use the library instead I want to do this in Android using JAVA. Let me know if anyone has done this before.
Thanks
Ravi
Reference link
This library may help you: https://github.com/MasayukiSuda/Mp4Composer-android
This library generates an Mp4 movie using Android MediaCodec API and can rotate Mp4.
StackOverflow reference: https://stackoverflow.com/a/19392712/8572503
It's API is fluent and easy :
new Mp4Composer(sourceFile, destinationFile)
.rotation(Rotation.ROTATION_90)
.size(1280,720) //720P
.fillMode(FillMode.PRESERVE_ASPECT_FIT)
.listener(new Mp4Composer.Listener() {
#Override
public void onProgress(double progress) {
Log.d(TAG, "onProgress = " + progress);
//or show in notification
}
#Override
public void onCompleted() {
Log.v(TAG, "onCompleted() : Destination → "+ destinationFile);
}
#Override
public void onCanceled() {
Log.d(TAG, "onCanceled");
}
#Override
public void onFailed(Exception exception) {
Log.wtf(TAG, "onFailed()", exception);
}
})
.start();
You can also see this transcoder has written in pure Java: https://github.com/ypresto/android-transcoder
[EDIT: From Comment]:
You can extract code from this: https://github.com/javadev/hexeditor to manually modify the hex.

Realtime Multiplayer Google Play Service combined with LibGDX

I am new to game development, and i'm struggling a bit with combining the google play service realtime multiplayer functionality in my LibGDX game. I do not find a lot of tutorials regarding this online.
I have downloaded the BaseGameUtils library, and everything is connected (my signIn method works), and i'm using interfaces to combine the android package with my core package.
In my AndroidLauncher, i have this code:
#Override
public void startQuickGame() {
final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 1;
Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(MIN_OPPONENTS, MAX_OPPONENTS, 0);
RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder((RoomUpdateListener) this);
rtmConfigBuilder.setMessageReceivedListener((RealTimeMessageReceivedListener) this);
rtmConfigBuilder.setRoomStatusUpdateListener((RoomStatusUpdateListener) this);
rtmConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
//prevent screen from sleeping
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Games.RealTimeMultiplayer.create(gameHelper.getApiClient(), rtmConfigBuilder.build());
}
I try to use the code in my Menu class:
#Override
protected void handleInput() {
if (Gdx.input.justTouched() && isOnBtn()) {
try {
crush.playServices.startQuickGame();
} catch (Exception e) {
e.printStackTrace();
}
gsm.set(new OnlineMultiplayerState(gsm));
dispose();
I'm not sure about how i should actually start the game?
At this point, everything just go black.
I would also like to use the code for methods like
handleSelectPlayersResult(int response, Intent data)
The problem is that when i try to define this method in my interface, it wont work because Intent only work in the Android package (not in core where my interface is).
Do you have an suggestion to how i can solve this?
Thank You!

Google Drive Api can't open all file formats

Hi I tried to open some files from Google Drive in andoid app using Google Drive Api with:
ResourceClient.openFile(selectedFile.asDriveFile() , DriveFile.MODE_READ_WRITE)
My code worked just fine for Word format (docx), but for all ohters format i tried it threw
com.google.android.gms.common.api.ApiException: 10: This file is not openable.
exception. This exception is nowhere to be found and i really couldn't get rid of it. If anybody can help I would be really grateful.
EDIT: Btw. I claimed metadata for all files successfully.
EDIT 2: Even while using Google samples i could open just Word documents.
Code that I used just in case you would need it:
Signing in to google:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(Drive.SCOPE_FILE)
.build();
signInClient = GoogleSignIn.getClient(getApplicationContext(), gso);
startActivityForResult(signInClient.getSignInIntent(), SING_IN_REQEST_CODE);
Geting metadata and files:
contentsTask = resourceClient.getMetadata(selectedFile.asDriveResource())
.continueWithTask(new Continuation<Metadata, Task<DriveContents>>(){
#Override
public Task<DriveContents> then(#NonNull Task<Metadata> task) throws Exception {
if(task.isComplete() && task.isSuccessful()) {
Log.d(TAG, "Metadata claimed sucessfully");
if(task.getResult().isEditable())
Log.d(TAG, "File is edittable");
return resourceClient.openFile(selectedFile.asDriveFile() , DriveFile.MODE_READ_WRITE);
}
else {
Log.i(TAG, "Metadata wasn't claimed sucessfully" + task.isComplete());
return null;
}
}
} ).addOnSuccessListener(new OnSuccessListener<DriveContents>() {
#Override
public void onSuccess(DriveContents driveContents) {
Log.i(TAG, "successfully get driveContents");
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.i(TAG, "didn't successfully get driveContents", e);
}
});
EDIT: Issue has been replicated by: https://github.com/googledrive/android-demos/issues/70
So, I left and come back this topic 2 times, but for others: Despide the fact that i didn't find ANY DOCUMENTATION that would say that, Android Drive API (and my friend told me exactly same expirience with Java API) can only download files:
PDF
Pictures
and can not download:
office formats
If anybody would have anything to add (like I overlooked huge documentaion on topic wich formats can you acces with Drive APIs please let me know.-

FileObserver not working on Android 6, alternative to detect screenshots on Android

I am trying to detect screenshots on Android app using fileObserver, fileObserver does not work on Android 6 as expected.
Here is the snippet which detects the screenshot:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screenshot_detection);
observer = new FileObserver(Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_PICTURES
+ File.separator + "Screenshots" + File.separator, FileObserver.ALL_EVENTS) {
#Override
public void onEvent(int event, String path) {
if (event == FileObserver.CREATE) {
Log.i(TAG, "Screenshot detected # " + path);
}
}
};
observer.startWatching();
}
I observe that the same code works on Nexus 5 running 4.4.4 where as does not work (the onEvent is never triggered) on Nexus 5 running 6.0.1 though I have taken care of run-time permissions for API 23+.
I see a known issue with fileObserver for Android M, is there a better alternative for detecting screenshots?
I tried contentObserver, faced issues with it as well.
You can check if, the
com.android.systemui:screenshot
process is running or not. If this is running then there is good chance that screen shot was taken while the user was on your app.
Try this code block,
private void screenShotTaken(Activity activity) {
final Handler handler = new Handler();
final int delay = 3000;
final ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
handler.postDelayed(new Runnable() {
public void run() {
List<ActivityManager.RunningServiceInfo> services = am.getRunningServices(200);
for (ActivityManager.RunningServiceInfo ar : services) {
if (ar.process.equals("com.android.systemui:screenshot")) {
Toast.makeText(activity, "Screenshot is taken!!", Toast.LENGTH_SHORT).show();
}
}
handler.postDelayed(this, delay);
}
}, delay);
}
This would be something which would keep on running with some delay and will give you enough chance to detect if the screenshot was taken or not. Also, you may like to check this git, where the whole code for the screenshot is there, I think it would take a just a little understanding how things are working.
Android 6.0 have extra security features, that is why it does not allow any application from unknown source to access any thing.
For the time being you can go the application manager then to your app and then go to permissions and then allow storage permission.
I hope this might help you now for the time being.

Set UsbDeviceListener javax.usb/usb4java

I tried to set the UsbDeviceListener but nothing happens when I disconnect the device nor when I create a new file on the device.
Can someone tell me where is the problem in my code?
public static void listPeripherique(UsbHub hub) {
List perepheriques = hub.getAttachedUsbDevices();
Iterator iterator = perepheriques.iterator();
while (iterator.hasNext()) {
UsbDevice perepherique = (UsbDevice) iterator.next();
perepherique.addUsbDeviceListener(new UsbDeviceListener() {
#Override
public void usbDeviceDetached(UsbDeviceEvent arg0) {
System.out.println("connect " + arg0);
}
#Override
public void errorEventOccurred(UsbDeviceErrorEvent arg0) {
System.out.println("disconect " + arg0);
}
#Override
public void dataEventOccurred(UsbDeviceDataEvent arg0) {
System.out.println("new data on " + arg0);
}
});
}
if (perepherique.isUsbHub()) {
listPeripherique((UsbHub) perepherique);
}
}
Edit: It's work only for usb Detached.
Do you mind giving use more details on your environment (Linux, Win, OSX) and what kind of USB device (Stick, Gamepad, DVD-Burner, Dongle, iP(a|o)d, iPhone, Smartphone)? However, if you use Windows, it seems the driver is out-of-date: JSR80: This is an ABANDONED Windows implementation. it does not work, it needs a kernel driver.
Keep us posted on your project and progress.
Edit
I tried it with my Logitech Wingman controller and I can confirm that only usbDeviceDetached events are raised. I think the driver is really outdated :(
Sounds like it is working correctly.
Your code iterates once over all currently connected devices and registers a device listener on it. When the device is disconnected then the usbDeviceDetached event is triggered. The other two events are triggered after data is transfered from or to the device by your own program or when an error occurred when your program tried to communicate with the device.
javax-usb can't monitor data transfers made by other programs. Maybe this is what you expected? For this you need a special USB monitor tool like usbmon on Linux.

Categories

Resources