- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试访问另一个类中的一个类,但可能会出现此错误。我正在使用 sinch 在我的应用程序中实现应用程序到应用程序的电话调用,但它仍然无法正常工作。
这是我的错误
FATAL EXCEPTION: main
Process: com.example.thinker.myapplication2, PID: 10039
java.lang.NullPointerException: Attempt to invoke virtual method 'com.sinch.android.rtc.calling.Call com.example.thinker.myapplication2.SinchService$SinchServiceInterface.callUser(java.lang.String)' on a null object reference
at com.example.thinker.myapplication2.tabs.Chatting$Bases.callButtonClicked(Chatting.java:128)
at com.example.thinker.myapplication2.tabs.Chatting$1.onClick(Chatting.java:83)
at android.view.View.performClick(View.java:5265)
at android.view.View$PerformClick.run(View.java:21534)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5683)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
这是我的 java 类。
public class Chatting extends ListActivity {
Runnable refresh, refres;
ImageView send,back,call;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yon);
call= (ImageView)findViewById(R.id.call);
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (!isOnline(Chatting.this)) {
Toast.makeText(Chatting.this, "No network connection",
Toast.LENGTH_SHORT).show();
return;
}
Bases ba = new Bases();
ba.onServiceConnected();
ba.callButtonClicked();
}
});
}
public class Bases extends BaseActivity {
@Override
protected void onServiceConnected() {
Toast.makeText(this, " call ready", Toast.LENGTH_LONG).show();
}
public void callButtonClicked() {
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(this);
String emaill = sp.getString("friend_email", "anon");
if (emaill.isEmpty()) {
Toast.makeText(this, "Please enter a user to call", Toast.LENGTH_LONG).show();
return;
}
try {
Call call = getSinchServiceInterface().callUser("emaill");
if (call == null) {
// Service failed for some reason, show a Toast and abort
Toast.makeText(this, "Service is not started. Try stopping the service and starting it again before "
+ "placing a call.", Toast.LENGTH_LONG).show();
return;
}
String callId = call.getCallId();
Intent callScreen = new Intent(this, CallScreenActivity.class);
callScreen.putExtra(SinchService.CALL_ID, callId);
startActivity(callScreen);
} catch (MissingPermissionException e) {
ActivityCompat.requestPermissions(this, new String[]{e.getRequiredPermission()}, 0);
}
}
}
}
下面是具有 getSinchServiceInterface() 的基本 Activity 类。返回 null
public abstract class BaseActivity extends Activity implements ServiceConnection {
private SinchService.SinchServiceInterface mSinchServiceInterface;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getApplicationContext().bindService(new Intent(this, SinchService.class), this,
BIND_AUTO_CREATE);
}
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
if (SinchService.class.getName().equals(componentName.getClassName())) {
mSinchServiceInterface = (SinchService.SinchServiceInterface) iBinder;
onServiceConnected();
}
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
if (SinchService.class.getName().equals(componentName.getClassName())) {
mSinchServiceInterface = null;
onServiceDisconnected();
}
}
protected void onServiceConnected() {
// for subclasses
}
protected void onServiceDisconnected() {
// for subclasses
}
protected SinchService.SinchServiceInterface getSinchServiceInterface() {
return mSinchServiceInterface;
}
}
最佳答案
大多数情况下,当有人使用错误的方式传递上下文时,尝试将上下文作为 YourActivityName.this (例如 Bases.this )而不只是 this 或 getApplicationContext() 传递,就会发生这种情况
开始于
@Override
protected void onServiceConnected() {
Toast.makeText(Bases.this, " call ready", Toast.LENGTH_LONG).show();
}
这不是调用 Activity 的正确方法
Bases ba = new Bases();
ba.onServiceConnected();
ba.callButtonClicked();
使用
Intent intent = new Intent(YourCurrentActivityName.this,Bases.class);
startActivity(intent);
在oncreate方法中你可以调用这个方法callButtonClicked()
关于java - Sinch 调用按钮错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44019939/
我从this下载了代码。我成功生成了应用程序 key 。 我实现了上面下载的示例中的示例代码,它在移动和网络上运行良好。但是当我尝试实现视频通话时出现错误 检索媒体流时出错 Overconstrain
我正在尝试访问另一个类中的一个类,但可能会出现此错误。我正在使用 sinch 在我的应用程序中实现应用程序到应用程序的电话调用,但它仍然无法正常工作。 这是我的错误 FATAL EXCEPTION:
无人应答调用以“超时”状态结束之前的时间似乎为 45 秒。 可以在 JS 或 Android api 中的任何位置进行调整吗? 最佳答案 不在 SDK 中,但如果您给我发邮件,我会在配置中为您更改它。
我已经使用 Parse + Sinch 设置了一个聊天应用程序(我主要使用 this official tutorial),并且我正在尝试以特定方式获取通知: 当MessagingActivity打开
是否可以基于唯一用户获得累积的 call 建立时间? 我在仪表板上找不到该信息。 最佳答案 该信息在Sinch仪表板中不可用,但可以通过REST API访问。作为合作伙伴,您还可以下载可用于收集这些指
我们可以使用 sinch api 在 swift 中创建一个即时消息应用程序吗?我尝试在 swift 应用程序中导入 sinch 框架,但导入后无法将 sinch 类导入到我的应用程序中。请帮忙。 最
SINCallDelegate 的所有委托(delegate)方法都工作正常,但大多数时候,尽管客户端连接成功,但音频无法工作。 最佳答案 Swift- 5 非常简单,我就完成了 //MARK:- a
我正在开发 Android 聊天应用程序,一切都很顺利。我已经设法将用户添加到解析数据库并在 friend fragment 上显示用户。 但后来 Sinch 来了。我按照他们网站上的说明将 SDK
我关注了 sinch tutorial用于制作消息传递应用程序。基于本教程,sinch 客户端从主要 Activity 开始。我能够使用 Parse 发送推送通知并创建一个通知生成器,但是当用户点击它
我需要使用 Sinch API 发送带有阿拉伯语文本的短信。我的短信包含 - 英语、阿拉伯语和数字号码。 我尝试过的 我已经阅读了 Sinch 的文档,但他们没有提供任何有关如何使用 UTF-16BE
如果应用程序在 iPhone(iOS 10) 中处于关闭状态,则无法发起调用。 我正在使用推送套件服务进行调用。如果应用程序在后台,我正在接听电话,但如果应用程序处于关闭状态,则会收到来自服务器的通知
我已经在 ios swift 项目中实现了 sinch 视频通话我已经遵循了 sinch 实现文档中给出的所有过程 https://www.sinch.com/docs/video/ios/#call
我实现了 Sinch + PushKit + CallKit,一切正常,但有一个脚本无法正常工作。第一个用户使用应用程序并将其从设备内存中删除,第二个用户第一次调用,第一个用户没有接听电话,如果第二个
我正在尝试在 Sinch 3.0.1 SDK 中运行消息传递示例应用程序。在 src 文件中,这一行: package com.sinch.android.rtc.sample.pstn; 抛出错误。
如何在Android中将sinch的远程 View 设置为全屏。 我尝试了 VideoController.setResizeBehaviour,但它不起作用。 最佳答案 您需要使用 Sinch se
我在我的项目中尝试了一个 sinch 视频通话示例,但是,我无法理解 sinch 视频通话示例中 sinchservice 类中的 CALL_ID 是什么。 最佳答案 这只是自定义字段名称,将在您接到
我想使用 sinch 创建一个 android 付费通话应用程序。sinch 包含一个回调 API 来获取调用的详细信息。我想使用它,但不知道如何使用。我阅读了文档。但这还不够 我的问题是, 对服务器
我已经正确设置了从推送通知开始调用的所有内容,但是接收者的 SINClient 没有调用 client:didReceiveIncomingCall: 方法,所以用户不可能接听电话。 我已经验证我的有
我希望我的 sinch 应用程序调用一个号码并要求应答者输入一个号码以选择他的语言。 到目前为止,我可以让她使用 POST 请求调用电话,其正文为: { "method
我只想在我的应用程序中使用sinch进行调用,到目前为止我已经关注了官方documentation因此,按照此链接,我正在构建 Sinch 客户端,如下所示: private var sinchCl
我是一名优秀的程序员,十分优秀!