小编Edr*_*ric的帖子

为什么调用Process.killProcess(Process.myPid())是个坏主意?

我读过一些帖子说使用这种方法"不好",不应该使用,这不是"关闭"应用程序的正确方法,而不是android的工作方式......

我理解并接受这样一个事实,即在正确的时间终止这个过程时Android OS比我更清楚,但我没有听到一个很好的解释为什么使用这个killProcess()方法是错误的?毕竟 - 它是android API的一部分......

我所知道的是,调用此方法时,其他线程正在执行潜在的重要工作(对文件的操作,写入数据库,HTTP请求,运行服务......)可以在中间终止,而且显然不是很好.此外,我知道我可以从"重新打开"应用程序将更快的事实中受益,因为系统可能仍然从上次使用时"保持"在内存状态,并killProcess()防止这种情况.

除了这个原因,假设我没有这样的操作,而且我不在乎我的应用程序会从头开始每次运行,还有其他原因为什么不使用这个killProcess()方法?

我知道关闭一个Activity的finish()方法,所以请不要写我这个... finish()仅供参考Activity.不是所有应用程序,我想我确切知道为什么以及何时使用它...

还有一件事 - 我正在使用Unity3D框架开发游戏,并将项目导出到android.当我反编译生成的apk时,我非常惊讶地发现java源代码是从Unity创建的 - 实现Unity的finish()方法,用Activity.

Application.quit()假设是根据Unity3d指南关闭游戏的正确方法(它真的吗?也许我错了,并且错过了一些东西),那么Unity的框架开发人员如何做得非常好,因为它似乎实现了这个原生android到Process.killProcess(Process.myPid())

android kill-process unity-game-engine

25
推荐指数
3
解决办法
1万
查看次数

缺少主调度程序的模块

我正在尝试对我的本地数据库进行后台调用,并使用协同程序使用结果更新UI.这是我的相关代码:

import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.Dispatchers.IO
import kotlinx.coroutines.experimental.Dispatchers.Main
import kotlin.coroutines.experimental.CoroutineContext
import kotlin.coroutines.experimental.suspendCoroutine

class WarehousesViewModel(private val simRepository: SimRepository)
: BaseReactViewModel<WarehousesViewData>(), CoroutineScope {

private val job = Job()

override val coroutineContext: CoroutineContext
    get() = job + Main

override val initialViewData = WarehousesViewData(emptyList())

override fun onActiveView() {
    launch {
        val warehouses = async(IO) { loadWarehouses() }.await()
        updateViewData(viewData.value.copy(items = warehouses))
    }
}

private suspend fun loadWarehouses(): List<Warehouse> =
    suspendCoroutine {continuation ->
        simRepository.getWarehouses(object : SimDataSource.LoadWarehousesCallback {
            override fun onWarehousesLoaded(warehouses: List<Warehouse>) {
                Timber.d("Loaded warehouses")
                continuation.resume(warehouses)
            }

            override …
Run Code Online (Sandbox Code Playgroud)

android coroutine kotlin kotlinx.coroutines

24
推荐指数
4
解决办法
8587
查看次数

简单的 Angular 9 项目编译整个 Angular Material(es2015 为 esm2015)

我创建了一个简单的 Angular 9 项目,其中只有几个简单的组件。我使用以下方法添加了角材料:

ng add @angular/material
Run Code Online (Sandbox Code Playgroud)

完成后,我运行npm start并注意到它开始使用一堆我不在我的应用程序中使用的@angular/material/* 组件编译整个@angular:

Compiling @angular/cdk/keycodes : es2015 as esm2015
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/core : es2015 as esm2015
Compiling @angular/cdk/collections : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/cdk/observers : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/cdk/platform : es2015 as esm2015
Compiling @angular/cdk/accordion : es2015 as esm2015
Compiling @angular/cdk/portal …
Run Code Online (Sandbox Code Playgroud)

angular-material angular

23
推荐指数
1
解决办法
2万
查看次数

如何在 GitHub Actions 中缓存 yarn 包

我正在使用 GitHub Actions 来构建我的 TypeScript 项目。每次运行操作时,我都会等待 3 分钟以安装所有依赖项。

有没有办法缓存纱线依赖项,所以构建时间会更快?

我试过这个:

     - name: Get yarn cache directory path
       id: yarn-cache-dir-path
       run: echo "::set-output name=dir::$(yarn cache dir)"

     - uses: actions/cache@v1
       id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
       with:
         path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
           ${{ runner.os }}-yarn-

    - name: Install yarn
      run: npm install -g yarn

    - name: Install project dependencies
      run: yarn
Run Code Online (Sandbox Code Playgroud)

但构建时间仍然相同。

typescript yarnpkg github-actions

22
推荐指数
4
解决办法
9992
查看次数

获取错误"mat-nav-list不是已知元素"

获取错误"mat-nav-list不是已知元素",使用@ angular/material"version"^ 5.2.5", - 请帮帮我

angular-material angular

20
推荐指数
4
解决办法
1万
查看次数

如何摆脱AngularJS Material插入的多个样式标签?

AngularJS Material使用md-theme-style属性插入多个(大约30个)样式标记.我想这是某种性能调整,但我宁愿自己做 - 我不需要外部框架来以这种讨厌的方式污染我的HTML.关于如何摆脱样式标签的任何想法?

angularjs angularjs-material

19
推荐指数
1
解决办法
1494
查看次数

如何在角度材质表的mat-row上添加click事件

我添加了这个但是在使用Chrome DevTools检查元素时,点击功能没有显示!

这是我的代码:

  <mat-table [dataSource]="dataSource1" class="mat-table">
    <!-- Position Column -->
    <ng-container matColumnDef="Objname">
      <mat-header-cell *matHeaderCellDef> ObjName </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.objname}} </mat-cell>
    </ng-container>
    <!-- Weight Column -->
    <ng-container matColumnDef="Successcount">
      <mat-header-cell *matHeaderCellDef> Successcount   </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.successcount}} </mat-cell>
    </ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row (click)="getRecord(element.objname)" *matRowDef="let row; columns: displayedColumns;"></mat-row>
  </mat-table>
Run Code Online (Sandbox Code Playgroud)

typescript angular-material angular

19
推荐指数
4
解决办法
3万
查看次数

媒体播放器控制在通知中

我已经编写了完整的音乐播放器来播放来自网络的音乐,但我不知道如何将媒体播放器控件置于通知中以及何时屏幕是锁定.

我按照本教程 在通知栏中显示控件,但仍未获得如何在我的程序中使用相同的功能,我已导入所需的类,如:NotificationService.javaConstants.java.

这是我在通知栏中得到的:

[通知]

我很迷惑.为什么我没有得到我正在播放的歌曲的标题,为什么暂停,上一个和下一个按钮不起作用等...

NotificationService.java:

public class NotificationService extends Service {

    Notification status;
    private final String LOG_TAG = "NotificationService";

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }


    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        if (intent.getAction().equals(Constants.ACTION.STARTFOREGROUND_ACTION)) {
            showNotification();
            Toast.makeText(this, "Service Started", Toast.LENGTH_SHORT).show();  
        } else if (intent.getAction().equals(Constants.ACTION.PREV_ACTION)) {
            Toast.makeText(this, "Clicked Previous", Toast.LENGTH_SHORT).show();
            Log.i(LOG_TAG, "Clicked Previous");
        } else if (intent.getAction().equals(Constants.ACTION.PLAY_ACTION)) {
            Toast.makeText(this, "Clicked …
Run Code Online (Sandbox Code Playgroud)

notifications android lockscreen android-music-player

18
推荐指数
1
解决办法
2万
查看次数

如何实现Material Design规定的"父母对子"导航过渡

当父级由列表组成时,Google的"材料设计"指南规定了"父级到子级"转换的以下转换.(材料设计指南)

我如何提供这样的过渡?我不知道为实现这一目标而提供的任何内置过渡.

android material-design

17
推荐指数
2
解决办法
6167
查看次数

角度材质自定义选项卡

我正在使用角4,我正在使用Angular Material.

<md-tab-group [disableRipple]=true>
    <md-tab label="Tab 1"></md-tab>
    <md-tab label="Tab 2"></md-tab>
</md-tab-group>
Run Code Online (Sandbox Code Playgroud)

如何(未选择/选择),文本颜色等我可以完全自定义背景颜色.我已经尝试过使用伪类......但仍无济于事.---我已font-size成功设置,但文本颜色设置时有点紧张.请帮忙.

更新:

我已经尝试在选中后将背景更改为透明...当在选项卡中未选择链接时尝试覆盖颜色等等但仍然无法正常工作.

/* Styles go here */

  .mat-tab-label{
    color:white;
    min-width: 25px !important;
    padding: 5px;
       background-color:transparent;
        color:white;
        font-weight: 700;
  }

  /deep/ .mat-tab-label{
    min-width: 25px !important;
    padding: 5px;
       background-color:transparent;
        color:white;
        font-weight: 700;
}

.md-tab.ng-scope.ng-isolate-scope.md-ink-ripple.md-active{
      background-color:transparent;
      color:white;
      font-weight: 700;
  }

.md-tab.ng-scope.ng-isolate-scope.md-ink-ripple{
    background-color:transparent;
    color:white;
    font-weight: 700;
}



.mat-tab-label:active{
    min-width: 25px !important;
    padding: 5px;
       background-color:transparent;
        color:white;
        font-weight: 700;
}

.mat-tab-label:selected{
    min-width: 25px !important;
    padding: 5px;
       background-color:transparent;
        color:white;
        font-weight: 700; …
Run Code Online (Sandbox Code Playgroud)

angular-material2 angular

17
推荐指数
3
解决办法
4万
查看次数