Get result metadata using hal3 in android - android

this problem is about HAL3 of android
I want to know when use capture method in CameraDevice.
is it real working class which is CameraDevice.CaptureListener?
it was possible to get image data but couldn't receive result metadata.
this is ResultMetaDataListener.
class ResultMetaDataListener extends CameraDevice.CaptureListener{
#Override
public void onCaptureStarted(CameraDevice camera, CaptureRequest request, long timestamp) {
// TODO Auto-generated method stub
super.onCaptureStarted(camera, request, timestamp);
}
#Override
public void onCaptureCompleted(CameraDevice camera, CaptureRequest request, CaptureResult result) {
// TODO Auto-generated method stub
super.onCaptureCompleted(camera, request, result);
Log.i(TAG, "Capture result is available");
Integer reqCtrlMode;
Integer resCtrlMode;
if (request == null || result ==null) {
Log.e(TAG, "request/result is invalid");
return;
}
Log.i(TAG, "Capture complete");
and this is capture Method. mCamera is CameraDevice object.
ResultMetaDataListener resultListener = new ResultMetaDataListener();
mCamera.capture(captureBuilder.build(), resultListener, mOpsHandler);
please, help me if you know about that

Related

Wrong Callback gets fired while verifying received OTP using Sinch SMS Verification in android

I am integrating Sinch SMS Verification API in my app and half part is already done. So far, I am able to send and generate OTP request/response for given mobile number and receiving on that mobile number. However, when I try to VERIFY that received OTP wrong Callback gets fired.
Below is my code,
public class MainActivity extends AppCompatActivity implements OnClickListener, VerificationListener {
private EditText editTextVerify;
private Button buttonVerify;
private Config config;
private Verification verification;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editTextVerify = (EditText) findViewById(R.id.editTextVerify);
buttonVerify = (Button) findViewById(R.id.buttonVerify);
buttonVerify.setOnClickListener(this);
config = SinchVerification.config().applicationKey("5xxxxx9c-xxc-4***-a***-76xxxxxb1xx1").context(getApplicationContext()).build();
verification = SinchVerification.createSmsVerification(config, "91xx**xx**", this);
verification.initiate();
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("...button clicked...");
verification.verify(editTextVerify.getText().toString().trim());
}
#Override
public void onInitiated() {
// TODO Auto-generated method stub
System.out.println("...calls onInitiated...");
}
#Override
public void onInitiationFailed(Exception e) {
// TODO Auto-generated method stub
if (e instanceof InvalidInputException) {
// Incorrect number provided
System.out.println("....onInitiationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof ServiceErrorException) {
// Sinch service error
System.out.println("....onInitiationFailed exception... " + e.getLocalizedMessage());
} else {
// Other system error, such as UnknownHostException in case of network error
System.out.println("....onInitiationFailed exception... " + e.getLocalizedMessage());
}
}
#Override
public void onVerified() {
// TODO Auto-generated method stub
System.out.println("...callls onVerified this....");
}
#Override
public void onVerificationFailed(Exception e) {
// TODO Auto-generated method stub
if (e instanceof InvalidInputException) {
// Incorrect number or code provided
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof CodeInterceptionException) {
// Intercepting the verification code automatically failed, input the code manually with verify()
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof IncorrectCodeException) {
// The verification code provided was incorrect
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof ServiceErrorException) {
// Sinch service error
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else {
// Other system error, such as UnknownHostException in case of network error
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
}
}
}
Whenever I enter received OTP or wrong OTP in the Text Box & click Submit button below callback gets fired this Callback
#Override
public void onInitiationFailed(Exception e) {
// TODO Auto-generated method stub
if (e instanceof InvalidInputException) {
// Incorrect number provided
System.out.println("....onInitiationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof ServiceErrorException) {
// Sinch service error
System.out.println("....onInitiationFailed exception... " + e.getLocalizedMessage());
} else {
// Other system error, such as UnknownHostException in case of network error
System.out.println("....onInitiationFailed exception... " + e.getLocalizedMessage());
}
}
Ideally, it should fire below Callback
#Override
public void onVerificationFailed(Exception e) {
// TODO Auto-generated method stub
if (e instanceof InvalidInputException) {
// Incorrect number or code provided
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof CodeInterceptionException) {
// Intercepting the verification code automatically failed, input the code manually with verify()
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof IncorrectCodeException) {
// The verification code provided was incorrect
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else if (e instanceof ServiceErrorException) {
// Sinch service error
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
} else {
// Other system error, such as UnknownHostException in case of network error
System.out.println("....onVerificationFailed exception... " + e.getLocalizedMessage());
}
}
Referred links :
https://www.sinch.com/docs/verification/android/#verificationlistener
I would try placing the onVerified callback right after the onInitiationFailed method. This should then allow the OTP response to pass through the onVerificationFailed callback.
Here's the documentation for the Verification Listener:
http://download.sinch.com/docs/verification/android/latest/reference/index.html

new PeerConnectionFactory() gives error on android

I am trying to implement WebRTC DataChannel on Android. I want to create a simple peerconnection object which will open DataChannel to send data over the network using WebRTC. I am getting error when I try to create my PeerConnection Object. I learnt that we use factory to create peerconnection object using factory.createPeerConnection().
For this, I have to create the PeerConnectionFactory object first. After this, I can use it to create PeerConnection Object. I get errors Could not find method android.media.MediaCodec.setParameters and Fatal Signal 11 (SIGSEGV) at 0x00000000 (code=1) when I try to create PeerConnectionFactory object. I also tried the following code with PeerConnectionFactory.initializeAndroidGlobals(this, false, false, false); This is what I am trying to do:
PeerConnectionFactory factory = new PeerConnectionFactory();
peer = new Peer();
This is how my Peer object looks like:
public class Peer implements SdpObserver, PeerConnection.Observer, DataChannel.Observer {
private PeerConnection pc;
private DataChannel dc;
public Peer() {
this.pc = factory.createPeerConnection(RTCConfig.getIceServer(),
RTCConfig.getMediaConstraints(), this);
dc = this.pc.createDataChannel("sendDataChannel", new DataChannel.Init());
}
#Override
public void onAddStream(MediaStream arg0) {
// TODO Auto-generated method stub
}
#Override
public void onDataChannel(DataChannel dataChannel) {
this.dc = dataChannel;
}
#Override
public void onIceCandidate(final IceCandidate candidate) {
try {
JSONObject payload = new JSONObject();
payload.put("type", "candidate");
payload.put("label", candidate.sdpMLineIndex);
payload.put("id", candidate.sdpMid);
payload.put("candidate", candidate.sdp);
sendSocketMessageDataChannel(payload.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
#Override
public void onIceConnectionChange(IceConnectionState iceConnectionState) {
}
#Override
public void onIceGatheringChange(IceGatheringState arg0) {
// TODO Auto-generated method stub
}
#Override
public void onRemoveStream(MediaStream arg0) {
// TODO Auto-generated method stub
}
#Override
public void onRenegotiationNeeded() {
// TODO Auto-generated method stub
}
#Override
public void onSignalingChange(SignalingState arg0) {
// TODO Auto-generated method stub
}
#Override
public void onCreateFailure(String msg) {
Toast.makeText(getApplicationContext(),
msg, Toast.LENGTH_SHORT)
.show();
}
#Override
public void onCreateSuccess(SessionDescription sdp) {
try {
JSONObject payload = new JSONObject();
payload.put("type", sdp.type.canonicalForm());
payload.put("sdp", sdp.description);
sendSocketMessageDataChannel(payload.toString());
pc.setLocalDescription(FilePeer.this, sdp);
} catch (JSONException e) {
e.printStackTrace();
}
}
#Override
public void onSetFailure(String arg0) {
// TODO Auto-generated method stub
}
#Override
public void onSetSuccess() {
// TODO Auto-generated method stub
}
#Override
public void onMessage(Buffer data) {
Log.w("FILE", data.toString());
}
#Override
public void onStateChange() {
Toast.makeText(getApplicationContext(),
"State Got Changed", Toast.LENGTH_SHORT)
.show();
/*
byte[] bytes = new byte[10];
bytes[0] = 0;
bytes[1] = 1;
bytes[2] = 2;
bytes[3] = 3;
bytes[4] = 4;
bytes[5] = 5;
bytes[6] = 6;
bytes[7] = 7;
bytes[8] = 8;
bytes[9] = 9;
ByteBuffer buf = ByteBuffer.wrap(bytes);
Buffer b = new Buffer(buf, true);
dc.send(b);
*/
}
}
Can anybody point me to any sample source code which implements DataChannel on Android? Kindly also let me know if I am not doing it in a right way. I could not find the documentation for Android Native WebRTC which tells how to do it. I am trying to implement whatever I have learnt from using WebRTC on web.
Kindly, let me know if my question is not clear.
PeerConnectionFactory no longer requires initializing audio & video engines to be enabled.
PeerConnectionFactory.initializeAndroidGlobals(this, false, false, false);
Now you will be able to disable audio and video, and use data channels
This is a known bug in WebRTC code for Android. Following threads talk more on this bug:
https://code.google.com/p/webrtc/issues/detail?id=3416
https://code.google.com/p/webrtc/issues/detail?id=3234
The bug is currently in open status. However, there is a workaround available which will work for now. In Android Globals, we need to pass the audio and video parameters as true:
PeerConnectionFactory.initializeAndroidGlobals(getApplicationContext(), true, true, VideoRendererGui.getEGLContext());
Use this instead PeerConnectionFactory.initializeAndroidGlobals(acontext, TRUE, false, false, NULL);
Then create the factory. factory = new PeerConnectionFactory();
Then in your class Peer create the peer connection as this : factory.createPeerConnection(iceServers, sdpMediaConstraints, this);.
This worked for me to establish ONLY DataChannel without EGLContext for video streaming.
UPDATE: If you still have this error, go to a newer version! This is very deprecated.

Android facebook feed posting error

I'm trying to post on facebook from my android app. It is working fine using previously created app id.
Some thread is saying it is because of publish_actions.
But using new on it is giving following error.
Response: {"error":{"message":"(#200) Requires extended permission: publish_actions","type":"OAuthException","code":200}}
My posting code is below:
public void shareVideoInFacebook() {
mPrefs = getPreferences(MODE_PRIVATE);
byte[] data = null;
// shareAdvertisement();
String link = "http://techslides.com/demos/sample-videos/small.mp4";
String dataMsg = "Share for DateClip";
Bundle param;
facebook = new Facebook(APP_ID);
System.out.println("Access Token: " + pref.getFbAccessToken());
facebook.setAccessToken(pref.getFbAccessToken());
facebook.setAccessExpires(pref.getFbAccessExpire());
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
InputStream is = null;
try {
// is = new FileInputStream(dataPath);
// data = readBytes(is);
param = new Bundle();
param.putString("message", dataMsg);
param.putString("filename", "DateClip");
// param.putByteArray("video", data);
param.putString("name", "DateClip");
param.putString("caption",
"Build great social apps and get more installs.");
param.putString("description", "Watch the Video");
param.putString("link", link);
// param.putString("picture",
// "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
mAsyncRunner.request("me/feed", param, "POST",
new RequestListener() {
#Override
public void onMalformedURLException(
MalformedURLException e, Object state) {
// TODO Auto-generated method stub
}
#Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
System.out.println("IO Exception.........");
}
#Override
public void onFileNotFoundException(
FileNotFoundException e, Object state) {
// TODO Auto-generated method stub
// Toast.makeText(getApplicationContext(),
// "File not found...", Toast.LENGTH_LONG).show();
System.out.println("FileNotfound.........");
}
#Override
public void onFacebookError(FacebookError e,
Object state) {
// TODO Auto-generated method stub
// Toast.makeText(getApplicationContext(),
// "Error...", Toast.LENGTH_LONG).show();
System.out.println("Error.........");
}
#Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
// Toast.makeText(getApplicationContext(),
// "Sharing Completed...",
// Toast.LENGTH_LONG).show();
System.out
.println("Successfully Sent.......................................................");
System.out.println("Response: " + response);
runOnUiThread(new Runnable() {
public void run() {
// UI code goes here
Toast.makeText(getApplicationContext(),
"Successfully shared on Facebook.",
Toast.LENGTH_LONG).show();
// shareForPassionPoint();
}
});
}
}, null);
// mAsyncRunner.request(dataPath, parameters, httpMethod, new F,
// state);
} catch (Exception e) {
e.printStackTrace();
}
}
Please help me.
This was the case with out iOS app. It may be the same for Android also.
"
Please get your app reviewed again.
Recently, all the permissions except 3 basic ones (email, public_profile and user_friends) have been removed from the app if you had it reviewed by an older version of the Graph API.
Follow the steps as described here: https://developers.facebook.com/docs/facebook-login/review
"
Hope this helps :)

how to build BufferReceived() to capture voice using RecognizerIntent?

i am working on an android application using
RecognizerIntent.ACTION_RECOGNIZE_SPEECH,,, my problem is that i don't know how
to create the buffer which will capture the voice that the user inputs. i
read alot on stack overflow, but i just don't understand how
i will include the buffer and the recognition service call back into my code. AND HOW WILL I DO PLAY BACK FOR THE CONTENTS WHICH WERE SAVED INTO THE BUFFER.
this is my code:
public class Voice extends Activity implements OnClickListener {
byte[] sig = new byte[500000] ;
int sigPos = 0 ;
ListView lv;
static final int check =0;
protected static final String TAG = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.voice);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
"com.domain.app");
SpeechRecognizer recognizer = SpeechRecognizer
.createSpeechRecognizer(this.getApplicationContext());
RecognitionListener listener = new RecognitionListener() {
#Override
public void onResults(Bundle results) {
ArrayList<String> voiceResults = results
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
if (voiceResults == null) {
Log.e(TAG, "No voice results");
} else {
Log.d(TAG, "Printing matches: ");
for (String match : voiceResults) {
Log.d(TAG, match);
}
}
}
#Override
public void onReadyForSpeech(Bundle params) {
Log.d(TAG, "Ready for speech");
}
#Override
public void onError(int error) {
Log.d(TAG,
"Error listening for speech: " + error);
}
#Override
public void onBeginningOfSpeech() {
Log.d(TAG, "Speech starting");
}
#Override
public void onBufferReceived(byte[] buffer) {
// TODO Auto-generated method stub
TextView display=(TextView)findViewById (R.id.Text1);
display.setText("True");
System.arraycopy(buffer, 0, sig, sigPos, buffer.length) ;
sigPos += buffer.length ;
}
#Override
public void onEndOfSpeech() {
// TODO Auto-generated method stub
}
#Override
public void onEvent(int eventType, Bundle params) {
// TODO Auto-generated method stub
}
#Override
public void onPartialResults(Bundle partialResults) {
// TODO Auto-generated method stub
}
#Override
public void onRmsChanged(float rmsdB) {
// TODO Auto-generated method stub
}
};
recognizer.setRecognitionListener(listener);
recognizer.startListening(intent);
startActivityForResult(intent,check);
}
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
The Android speech recognition API (as of API level 17) does not offer a reliable way to capture audio.
You can use the "buffer received" callback but note that
RecognitionListener says about onBufferReceived:
More sound has been received. The purpose of this function is to allow
giving feedback to the user regarding the captured audio. There is no
guarantee that this method will be called.
buffer: a buffer containing a sequence of big-endian 16-bit
integers representing a single channel audio stream. The sample rate
is implementation dependent.
and RecognitionService.Callback says about bufferReceived:
The service should call this method when sound has been received. The
purpose of this function is to allow giving feedback to the user
regarding the captured audio.
buffer: a buffer containing a sequence of big-endian 16-bit
integers representing a single channel audio stream. The sample rate
is implementation dependent.
So this callback is for feedback regarding the captured audio and not necessarily the captured audio itself, i.e. maybe a reduced version of it for visualization purposes. Also, "there is no guarantee that this method will be called", i.e. Google Voice Search might provide it in v1 but then decide to remove it in v2.
Note also that this method can be called multiple times during recognition. It is not documented however if the buffer represents the complete recorded audio or only the snippet since the last call. (I'd assume the latter, but you need to test it with your speech recognizer.)
So, in your implementation you should copy the buffer into a global variable to be saved e.g. into a wav-file once the recognition has finished.

Facebook api and send invite to more than one friend in android

I have a problem with inviting firend by facebook api to my app. This is my method:
private void inviteFromFacebook(Activity activity, List<GraphUser> list) {
for(int i=0; i<list.size(); i++) {
//TODO post invite to friends wall
// Log.v("MainActivity", "user id: " + user.getId());
if(list == null || list.size() == 0)
return;
Bundle parameters = new Bundle();
String friendsIdsInFormat = "";
friendsIdsInFormat = friendsIdsInFormat + list.get(i).getId();
parameters.putString("to", friendsIdsInFormat);
parameters.putString( "message", "Use my app!");
Facebook mFacebook = new Facebook( getResources().getString(R.string.facebook_app_id));
// Show dialog for invitation
mFacebook.dialog(activity, "apprequests", parameters, new Facebook.DialogListener() {
#Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
}
#Override
public void onCancel() {
// TODO Auto-generated method stub
}
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
});
}
}
Everyting is ok, but I want to send invitation to many frieds, so in this codes I show one dialog for every person. How can I show only one dialog, but with many friends? This is possible or I must for every friend show dialog?
You can send a comma delimited list in the "to" field, like "123,456,789".
Be careful about sending too many requests though, you don't want to be identified as a spam app.

Categories

Resources