-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
开始尝试解决无障碍转账码,有时收到款后不会推送,等会再收到款后会把两条推送问题#95
- Loading branch information
Showing
8 changed files
with
239 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.weihuagu.receiptnotice; | ||
|
||
import android.app.Application; | ||
import android.app.Notification; | ||
import android.content.Intent; | ||
import android.content.Context.*; | ||
import android.app.PendingIntent; | ||
import android.app.Notification.Builder; | ||
import android.app.NotificationManager; | ||
import android.widget.Toast; | ||
|
||
|
||
import com.weihuagu.receiptnotice.action.HandlePost; | ||
import com.weihuagu.receiptnotice.view.MainActivity; | ||
|
||
public class ForTest { | ||
public void makeAPostTest(String pkg, Notification notification){ | ||
//接受推送处理 | ||
NotificationHandle notihandle =new NotificationHandleFactory().getNotificationHandle(pkg,notification,new HandlePost()); | ||
if(notihandle!=null){ | ||
notihandle.printNotify(); | ||
notihandle.handleNotification(); | ||
notihandle.removeNotification(); | ||
return; | ||
} | ||
} | ||
private void GenerateNotification() { | ||
Intent intent = new Intent(MainApplication.getAppContext(), MainActivity.class); | ||
PendingIntent pintent = PendingIntent.getActivity(MainApplication.getAppContext(), 0, intent, 0); | ||
Builder builder = new Builder(MainApplication.getAppContext()); | ||
builder.setSmallIcon(R.drawable.ic_launcher); | ||
builder.setTicker("这是手记状态栏提示"); | ||
builder.setWhen(System.currentTimeMillis()); | ||
builder.setContentTitle("woshi biaoti"); | ||
builder.setContentText("标题内容我是"); | ||
builder.setContentIntent(pintent); | ||
builder.setDefaults(Notification.DEFAULT_SOUND); | ||
builder.setDefaults(Notification.DEFAULT_LIGHTS); | ||
// builder.getNotification();//4.0以及以下版本用这个获取notification | ||
Notification notification = builder.build();// 4.1以及以上版本用这个 | ||
Toast.makeText(MainApplication.getAppContext(), "生成通知", 50).show(); | ||
NotificationManager manager = (NotificationManager) MainApplication.getAppContext() | ||
.getSystemService(android.content.Context.NOTIFICATION_SERVICE); | ||
manager.notify(23, notification);// 发出通知 | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/weihuagu/receiptnotice/OnlyWriteToDateBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.weihuagu.receiptnotice; | ||
|
||
import java.util.Map; | ||
import com.weihuagu.receiptnotice.util.DataBaseHolder; | ||
import com.google.gson.Gson; | ||
|
||
public class OnlyWriteToDateBase { | ||
DataBaseHolder database = DataBaseHolder.getInstance(); | ||
public void onePostWriteToDateBase(String postjson){ | ||
Gson gson=new Gson(); | ||
Map<String,String> postmap=gson.fromJson(postjson,Map.class); | ||
String type=postmap.get("type"); | ||
String time=postmap.get("time"); | ||
String title=postmap.get("title"); | ||
String money=postmap.get("money"); | ||
String content=postmap.get("content"); | ||
checkHavePlatName(type); | ||
|
||
} | ||
|
||
|
||
public boolean checkHavePlatName(String plattype){ | ||
database.sqliteDatabase.query("plat",new String[]{"name"},plattype,null,null,null,null); | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/weihuagu/receiptnotice/view/TestActiviy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.weihuagu.receiptnotice.view; | ||
|
||
import android.os.Bundle; | ||
import android.webkit.WebView; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.weihuagu.receiptnotice.R; | ||
import com.weihuagu.receiptnotice.ForTest; | ||
|
||
|
||
import org.w3c.dom.Text; | ||
import android.widget.Button; | ||
import android.view.View; | ||
|
||
public class TestActiviy extends AppCompatActivity implements View.OnClickListener{ | ||
|
||
private TextView money; | ||
private Button button; | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_test); | ||
money = (TextView) findViewById(R.id.money); | ||
button = (Button) findViewById(R.id.action_nitification); | ||
button.setOnClickListener(this); | ||
|
||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.action_nitification: | ||
new ForTest(); | ||
break; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.weihuagu.receiptnotice.view.MainActivity"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/my_toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" | ||
android:elevation="4dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
android:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> | ||
|
||
|
||
|
||
<LinearLayout | ||
android:id="@+id/inputlinearlayout" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:focusable="true" | ||
android:focusableInTouchMode="true" | ||
android:orientation="vertical" | ||
app:layout_constraintTop_toBottomOf="@id/my_toolbar"> | ||
|
||
<TextView | ||
android:id="@+id/money" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:inputType="text" | ||
android:text=""></TextView> | ||
|
||
<Button | ||
android:id="@+id/action_nitification" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="模拟通知" /> | ||
</LinearLayout> | ||
|
||
|
||
<androidx.viewpager2.widget.ViewPager2 | ||
android:id="@+id/viewpager" | ||
layout_constraintBottom_toBottomOf="parent" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_margin="0dp" | ||
android:orientation="horizontal" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/inputlinearlayout" | ||
app:layout_constraintVertical_bias="0.0" | ||
tools:layout_editor_absoluteX="-40dp" /> | ||
|
||
<com.google.android.material.floatingactionbutton.FloatingActionButton | ||
android:id="@+id/floatingshowlog" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="bottom|end" | ||
android:layout_margin="5dp" | ||
android:src="@drawable/log_icon" | ||
app:backgroundTint="@color/white" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" /> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |