我正在尝试在我的应用程序中实现Firebase云消息传递,我已经实现了所有设置以使用此服务,但是当我尝试FirebaseMessagingService在我的课程中进行扩展时,它给了我错误,它根本找不到它,我甚至无法import com.google.firebase.messaging.FirebaseMessagingService如图所示:
我添加了所有必需的代码:我将其添加到app gradle
compile 'com.google.firebase:firebase-core:9.4.0'
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
这对模块gradle:
classpath 'com.google.gms:google-services:3.0.0'
Run Code Online (Sandbox Code Playgroud)
这是清单代码:
<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>
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
Run Code Online (Sandbox Code Playgroud)
我将谷歌json文件添加到应用程序.所以,如果有人能帮助我,请
我正在尝试检查位图的方向并在需要时将其翻转,但在应用代码时出错.这是我的代码,而我试图使用ExifInterface翻转图像:
@RequiresApi(api = Build.VERSION_CODES.N)
public void flipping(Bitmap b)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.JPEG,100, bos);
byte[] bitmapdata = bos.toByteArray();
ByteArrayInputStream bs = new ByteArrayInputStream(bitmapdata);
try {
ExifInterface exif = new ExifInterface(bs);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_UNDEFINED);
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotateImage(b, 90);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotateImage(b, 180);
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotateImage(b, 270);
break;
case ExifInterface.ORIENTATION_NORMAL:
default:
break;
}
encoding();
} catch (IOException e) {
e.printStackTrace();
}
}
public static Bitmap rotateImage(Bitmap source, float angle) {
Matrix matrix = new …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,该应用程序将检测蓝牙信号(Sensoro 智能信标设备)并打开活动。但我希望应用程序仍然能够检测到信号,即使应用程序处于后台甚至被杀死。我使用了前台服务,当我打开应用程序并在活动之间移动时,它会检测到信号,但是当将应用程序发送到后台并打开其他应用程序时,侦听器会停止,尽管服务仍在工作。我正在打印日志。System.out.println("Sensoro 2" );即使我终止应用程序或打开另一个应用程序,也会继续打印。但是 BeaconManagerListener 中的打印日志不起作用。我尝试使用后台服务,但它也不起作用。您能否告知,当应用程序在后台或被杀死时,是否有一种方法可以使侦听器在服务中工作?这是服务代码:
public class MyService extends Service {
public static final String CHANNEL_ID = "ForegroundServiceChannel";
int service_timer=0;
Timer timer = new Timer();
SensoroManager sensoroManager;
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
sensoroManager = SensoroManager.getInstance(MyService.this);
String input = intent.getStringExtra("inputExtra");
System.out.println("Sensoro 2" );
createNotificationChannel();
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0, notificationIntent, 0);
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Foreground Service")
.setContentText(input) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用文本转语音来帮助盲人用户使用我的网站作为我项目的一部分,它在输入、选择和按钮元素方面对我来说效果很好。但我也想为标签元素等其他元素发声。我尝试使用 (for) 而不是 id 并尝试使用事件 (mouseover) 而不是 (Click) 但它没有用。你能帮我解决这个问题,或者有什么建议吗?这是我的代码:
<div class="all">
<form action="/action_page.php">
<div class="container">
<h1>Register</h1>
Select Voice: <select id='voiceList'></select> <br><br>
<p>Please fill in this form to create an account.</p>
<hr>
<input id='text1' type="text" placeholder="Enter Email" name="email" required>
<label id="email" for="email"><b>Email</b></label>
<br/>
<label for="email"><b>Name </b></label>
<input id='text2' type="text" placeholder="Enter Name" name="email" required>
<br/>
<label for="psw"><b>Password </b></label>
<input id='text3' type="password" placeholder="Enter Password" name="psw" required>
<br/>
<label for="psw-repeat"><b>Mobile </b></label>
<input id='text4' type="password" placeholder="Mobile" name="psw-repeat" required>
<br/>
<label for="psw"><b>Gender </b></label>
<select id = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用我的Android应用程序将一些数据存储在mysql数据库中。我正在使用okhttp3发送请求,但在此行出现一个错误:
client.newCall(request).execute();
Run Code Online (Sandbox Code Playgroud)
我在本地计算机和在线上尝试了它,但是它给了我同样的错误,这里是代码,
public class MainActivity extends AppCompatActivity {
String token1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("MainActivity is :" + FirebaseInstanceId.getInstance().getToken());
FirebaseMessaging.getInstance().subscribeToTopic("test");
FirebaseInstanceId.getInstance().getToken();
token1=FirebaseInstanceId.getInstance().getToken();
}
public void clicking(View view) {
OkHttpClient client = new OkHttpClient();
RequestBody body = new FormBody.Builder()
.add("Token",token1)
.build();
okhttp3.Request request = new okhttp3.Request.Builder()
.url("http://saleh923.byethost8.com/hii.html")
.post(body)
.build();
try {
client.newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是日志:
com.example.user.firebasenot E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.firebasenot, PID: 3280
java.lang.IllegalStateException: Could not execute method …Run Code Online (Sandbox Code Playgroud) 我正在 Spark 上运行 Python 脚本,但出现以下错误:ValueError:对象 (1) 的长度与字段 (2) 的长度不匹配。我将列出我正在运行的代码以及错误的屏幕截图:
conf = SparkConf().setMaster("local").setAppName("ApplySentimentModel")
sc = SparkContext(conf = conf)
spark = SparkSession(sc)
# read the sentiment tsv file into an rdd and split it based upon tab
# the test file should be in the following format
# label->tab->tweet
lines = sc.textFile("test_file.tsv").map(lambda x: x.split("\t"))
# define the schema
schema = StructType([StructField("target", StringType(), True), StructField("tweet", StringType(), True)])
# create dataframe from rdd
docs = spark.createDataFrame(lines, schema)
# define the processing pipeline (tokenize->tf->idf->label_indexer)
tokenizer …Run Code Online (Sandbox Code Playgroud) android ×4
java ×2
apache-spark ×1
html ×1
javascript ×1
mysql ×1
okhttp ×1
okhttp3 ×1
pyspark ×1
python ×1